Tuesday, 15 June 2010

Downloading Source Code - How'd you run the File?

So, you have managed to download some source code. What on earth do you do with it next? Well, if you do what I first did, you end up with a file and you want to run it. Having experience only of Windows to that point, I double clicked the file that I had downloaded. That only opened a folder with no files in it that appeared to be executable. Hmm.

OK, so doing some sensible checks through Google I discover that I have to turn on a file's executable flag before being able to run it. Right, sounds a bit like adding .exe to the end of the filename, not too onerous. Lets have a go at thi... Wait a fucking minute, what the fuck is chmod 0755? What on earth does that do? After another age of research (bear in mind I am just trying to execute a fucking file) I discover that linux has a whole series of file permissions. They can each be on or off. So what you end up with is a string of '1's or '0's to indicate the state of various permissions. In other words it is a binary number. When you convert the binary number to decimal you end up with something as intuitively obvious as 0755. Fucking spiffing. If I wanted to work in binary I would grow another 38 fucking legs and call myself an 8086 central processing unit.

Thankfully, there is a far more sensible alternative to that command. You can simply ask the system to:

 chmod +x filename

This [ch]anges the [mod]e of the [filename] to allow it to be e[x]ecuted. You can now try and run the file by double clicking the file. AAAAAAND nothing happens. OK, so lets drop to a command line, and change into the directory the file is in. Now type in the name of the file, AAAAAAND
command not found
Yes it is! I have found it! Look there it is in the fucking directory I typed the command in.

At this point I have to say I gave up. Several years later in my experience with Linux I found out that as with microsoft operating systems there is a PATH variable which contains a list of locations in the filesystem in which there are executable files. When the system reports "command not found", it actually means that the file has not been found in any of the directories listed in the PATH variable. The genius part of all this is that Linux DOES NOT HAVE YOUR CURRENT FOLDER IN THE PATH. That means that even if you can see the file you want to run you can't. What you need to do is to type in:


before the name of the file which tells the system that you want to run a file which is in the same directory. OK, so lets do that.
Cannot execute binary file
Brilliant. What next? After extensive research I discovered that you cannot simply run the file you have downloaded. Instead you have to 'make' it first. Which came as something of a fucking shock I can tell you - I thought the whole point was some other bugger made it and I used it? Oh, I see, to 'make' a file actually means to compile a working executable file from the source code? Well that makes sense, as long as you change the command from 'make' to 'compile'.

Find out the joys of trying to compile files next time.

No comments:

Post a Comment