shebang

Python deployment and /usr/bin/env portability

At the beginning of all my executable Python scripts I put the shebang line: #!/usr/bin/env python I'm running these scripts on a system where env python yields a Python 2.2 environment. My scripts quickly fail because I have a manual check for a compatible Python version: if sys.version_info < (2, 4): raise ImportError("Cannot r...

For ruby/webrick, I need windows to recognize shebang (#!) notation.

(Bear with me, I promise this gets to shebang and windows.) I have about the simplest of WEBRick servers put together: require 'webrick' include WEBrick s = HTTPServer.new(:Port=>2000, :DocumentRoot=>Dir::pwd) s.start Couldn't be simpler. This basic server does accept http connections (firefox, internet exploder, wget, TELENT) and ...

/usr/bin/env questions regarding shebang line pecularities

Questions: What does the kernel do if you stick a shell-script into the shebang line? How does the Kernel know which interpreter to launch? Explanation: I recently wanted to write a wrapper around /usr/bin/env because my CGI Environment does not allow me to set the PATH variable, except globally (which of course sucks!). So I thou...

Python source header comment

What is the line #!/usr/bin/env python in the first line of a python script used for? ...

What does #!/usr/bin/... at the start of a file mean?

I can do something like this in Haskell: #!/usr/bin/runghc main=putStrLn "Hello World" Then I can run it with ./hello.hs My question is, why is the first line ignored? Comments in haskell start with -- but the first line still seems to be ignored. It even loads in ghci. The trick also works with Python and Perl. But when I do someth...

How to address an issue while sourcing an env file in bash ?

Some issue arise when sourcing one of your env file (a series of variable exporting) for instance: ... export MY_ROOT=/Soft/dev/blah/blah export MY_BIN=${MY_ROOT}/bin ... results in $. my_env.sh $echo $MY_BIN /bint/dev/blah/blah => "/bin" seems to overwrite the begining of the variable instead of suffixing it.. Any idea? By the...

Rubygame on OS X shebang problem

I'm playing around with Rubygame. I installed it with the Mac Pack, and now I have the rsdl executable. rsdl game.rb works fine, but when I chmod +x the rb file, add the shebang to rsdl (tried direct path and /usr/bin/env rsdl) and try to execute it (./game.rb), it starts to flicker between the Terminal and rsdl which is trying to open, ...

How do I ignore the Perl shebang on Windows with Apache 2?

I have set up a local Perl web environment on my Windows machine. The application I'm working on is originally from a Linux server, and so the shebang for source .pl files look like so: #!/usr/bin/perl This causes the following error on my Windows dev machine: (OS 2)The system cannot find the file specified. Is it possible to chang...

Read the first line of batch file from the same batch file?

I have a batch file that tries to run the program specified in its first line. Similar to Unix's shebang: C:\> more foo.bat #!C:\Python27\python.exe %PYTHON% foo-script.py C:\> What I want to know is: is there a way to automatically set %PYTHON% to C:\Python27\python.exe which is specified in the first line of the script following the...

is there a hack for fully functional cross-platform shebang line?

Problem: apparently the scripts in the .git/hooks directory depend on the filename matching one of: post-commit pre-commit pre-rebase etc ... No concept of "file extension" is required because the "shebang line" indicates how the file should run, as long as it is executable and running on your Linux box. The problem is when you have...

Why do people write #!/usr/bin/env python on the first line of a Python script?

It seems to me like the files run the same without that line. ...

How do I set the taint mode in a perl script with a '#!/usr/bin/env perl'- shebang?

Hello, how do I set the taint mode in a perl script with a #!/usr/bin/env perl shebang? ...

What should I use for a Perl script's shebang line?

Which of these is better or faster to use as the shebang line for a Perl script? #! perl #! perl.exe #! fullpath/perl(/perl.exe) #! partialpath/perl(/perl.exe) And, when using #!perl, when it works on a particular system, how do I find out in the script which perl interpreter I'm using so I can put that one into the shebang line? ...

Portable shebang line

#!/usr/bin/perl This is the shebang line to a lot of scripts I'm writing lately. Hard coding the path of the binary seems like it could create some problems. For instance, if one of my users has Perl installed at /something_else/bin then they'd have to change all the shebangs. I've seen some tools that will automatically replace the ...

How does the #! work?

In a script you must include a #! on the first line followed by the path to the program that will execute the script (e.g.: sh, perl). As far as I know though, the # character denotes the start of a comment and that line is supposed to be ignored by the program executing the script. It would seem though, that this first line is at some p...

What's the shebang (#!) in Facebook and new Twitter URLs for?

EDIT [10/15]: added an example from the new Twitter too to make this question easier to search for. I've just noticed that the long, convoluted Facebook URLs that we're used to now look like this: http://www.facebook.com/example.profile#!/pages/Another-Page/123456789012345 As far as I can recall, earlier this year it was just a normal...

how to make a python or perl script portable to both linux and windows?

I was wondering how to make a python script portable to both linux and windows? One problem I see is shebang. How to write the shebang so that the script can be run on both windows and linux? Are there other problems besides shebang that I should know? Is the solution same for perl script? Thanks and regards! ...

shebang line not working in R script

I have the following script #!/usr/bin/Rscript print ("shebang works") in a file called shebang.r. When I run it from command line using Rscript it works $ Rscript shebang.r but when I run it from the command line alone $ shebang.r It doesn't work. shebang.r command not found. If I type (based on other examples I've seen) $ ....

Shebang line parsing problems in Ubuntu

What is the accepted, portable way to include interpreter options in the shebang line, ie. how can I do something like #!/usr/bin/env python -c or (more importantly) something like #!/usr/bin/env java -cp "./jars/*:./src" -Xmn1G -Xms1G -server and get it to be parsed correctly? Right now ubuntu seems to just glom the whole thing...

Cannot pass an argument to python with "#!/usr/bin/env python"

I needed to have a directly executable python script, so i started the file with "#!/usr/bin/env python". However, i also need unbuffered output, so i tried "#!/usr/bin/env python -u", but that doesn't work. ("python -u: no such file or directory") I found out that "#/usr/bin/python -u" works, but it doesn't suit my needs because i need...