On Mon, Oct 28, 2013 at 11:34 AM, Mark Lawrence <breamore...@yahoo.co.uk> wrote: > "What is the difference between "script" code (like Javascript and visual) > made for the screen (where such magic values are utilized) and compiled > source (made for the machine)?" > > This obviously impacts on the discussion above, so how does Unix, Windows > and other operating systems distinguish these with respect to binary, > executable, code library or whatever?
Suppose you pull up a shell - for argument's sake, let's say it's Debian GNU/Linux and you're running bash. You get a prompt that ends with a dollar sign, and you type "ls". What's going to get executed? * An alias? You might have an internal function defined in your .bashrc, or maybe a wrapper that adds parameters to your command. * A bash internal command? The shell might directly interpret what you specified. (I don't think ls is like that, but time is, on my systems.) * An external binary? On my systems, /bin/ls is an executable binary, compiled and ready to run. * A script? Another alternative to the shell alias, you could have /usr/local/bin/ls that does something different, then maybe drops through to /bin/ls. If it starts with "#!/usr/bin/python", it'll get dropped through to Python for execution. Chances are you wouldn't know the difference, as a human executing the commands. And you shouldn't need to care, except in really weird circumstances (maybe you broke your Python install and need to type "/bin/ls" to figure out what's going on). Most programs, trying to execute code, won't care about the difference between binaries and scripts, though of course exec*() won't parse bash aliases or internals. But if you need to distinguish for whatever reason, the easiest way is to look at the magic numbers, which can be done with the 'file' command: rosuav@sikorsky:~$ file `which ls` /bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.26, BuildID[sha1]=0x55f1e005df252708d4c456dcc2c7dccea1006553, stripped rosuav@sikorsky:~$ file `which zcat` /bin/zcat: Bourne-Again shell script, ASCII text executable Executables happily together, regardless of type. ChrisA -- https://mail.python.org/mailman/listinfo/python-list