Alex Rivera | Logout

What does it mean in linux scripts? #!/usr/bin/python -tt

Asked 2012-01-29T02:08:23.860
19

I know that in the begining of .sh bash scripts is

#!/bin/bash

which points to the command interpeter executable.

But during watching Google Python Class http://www.youtube.com/watch?v=tKTZoB2Vjuk I noticed that for python they use

#!/usr/bin/python -tt

. Surfing the Internet I also have found such styles of this notation:

#!/usr/local/bin/python

and even

#!/usr/bin/env python

.

So, I'm new with Python and I'm ordinary Linux user and I have a few questions about this "magic" line:

  1. First of all, what is the right form of this line? and why?
  2. What does -tt key means in #!/usr/bin/python -tt ?
  3. What program is parsing this line in Linux?
  4. What syntax of this line for any script?
  5. Why this line is so necessary if each file have it's extension?
  6. And what about that in each computer interpreter for some kind of scripts will be stored in different place than in another? And script couldn't be run.

It's really interesting to me. What's this line? Why this line? How to write this line? Why in such a way?...

Edit
Report

1 Answer

1
  1. #!/usr/bin/env python
  2. issue errors about inconsistent tab usage
  3. Kernel
  4. #!/path_to_the_interpreter or /usr/bin/env
  5. *nix does not check extensinon at all(except some DE could do that)
  6. This is why you should use #!/usr/bin/env

More info at wiki

answered 2012-01-29T02:19:46.757

Your Answer