I have a bunch of scripts (which can't be modified) written on Windows. Windows allows relative paths in its #!
commands. We are trying to run these scripts on Unix but Bash only seems to respect absolute paths in its #!
directives. I've looked around but haven't been able to locate an option in Bash or a program designed to replace and interpreter name. Is it possible to override that functionality -- perhaps even by using a different shell?
views:
54answers:
1
+2
A:
Typically you can just specify the binary to execute the script, which will cause the #!
to be ignored. So, if you have a Python script that looks like:
#!..\bin\python2.6
# code would be here.
On Unix/Linux you can just say:
prompt$ python2.6 <scriptfile>
And it'll execute using the command line binary. I view the hashbang line as one which asks the operating system to use the binary specified on the line, but you can override it by not executing the script as a normal executable.
Worst case you could write some wrapper scripts that would explicitly tell the interpreter to execute the code in the script file for all the platforms that you'd be using.
mjschultz
2010-07-19 20:55:08
Unfortunately the language I'm using doesn't use # as a comment so this won't work -- of course, this would be the answer if the language *did* support this so I'll give you the points.
wickedchicken
2010-07-20 19:36:08