Re: [Tutor] shebang problem
Alan Gauld said unto the world upon 11/04/2006 06:47 PM: > [EMAIL PROTECTED]:~/test$ ls -la shebangtest.py > -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py > > so the file is called shebangtest.py... > >> [EMAIL PROTECTED]:~/test$ shebangtest >> bash: shebangtest: command not found > > but you try to run shebangtest... > > bash can't find the file. you didn't put the .py on the end Well, shebangtest.py also didn't work as evidenced by one of the lines you snipped. > Also you may not have . in your path. For security reasons it isn't > there by default. > > Try > > [EMAIL PROTECTED]:~/test$ ./shebangtest.py And that would be it. It didn't occur to me to try ./shebangtest.py in lieu of the bare shebangtest.py. My command-line instinct were installed back in the days of using DOS on an XT. DOS (at least the version I used) first checked the cwd and only then searched the path. The security implications that Alan and Rick pointed to make the POSIX/bash behaviour make perfect sense on reflection, though. Thanks to all who replied, both on and off list, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] shebang problem
On Sat, November 4, 2006 11:07 am, Jonathon Sisson wrote: > Brian, > > It's not a permissions issue... > > (from the original e-mail...see below) > >> [EMAIL PROTECTED]:~/test$ ls -la shebangtest.py -rwxr-xr-- 1 brian > >> brian 68 2006-11-04 02:29 shebangtest.py > > This is clearly executable by brian, and clearly being executed by > brian. The shebang line is correct (#!/usr/bin/python). > [...] Good call. I jumped on the answer without making sure I clearly read all the information provided. -- Carlos Hanson > > Carlos Hanson wrote: >> >> Your answer lies in the file permission. The file needs to be >> executable. If you look at the man pages for chmod, you will find >> your answer. >> ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] shebang problem
Brian, It's not a permissions issue... (from the original e-mail...see below) >> [EMAIL PROTECTED]:~/test$ ls -la shebangtest.py >> -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py This is clearly executable by brian, and clearly being executed by brian. The shebang line is correct (#!/usr/bin/python). The problem is *how* you are executing the file. If you simply type in the filename, your shell looks on your PATH to find the file. Unless ~/test is on PATH, you'll get a "command not found" error. Instead type in: ./shebangtest.py and see if that works. "./" tells the shell to look in your current working directory for the file. Let me know if that solved the problem... Jonathon Carlos Hanson wrote: > On Sat, November 4, 2006 4:11 pm, Brian van den Broek wrote: >> Hi all, >> >> I'm still getting comfortable with Linux and this might be an OS >> rather than a python problem. >> >> I am trying to make a script directly executable. I've reviewed the >> 2nd ed of the Nutshell, and I cannot work out what I'm doing wrong. >> I'm running ubunutu 6.10 (edgy eft). Here's a copy past of my command >> line: >> >> [EMAIL PROTECTED]:~/test$ which python >> /usr/bin/python >> [EMAIL PROTECTED]:~/test$ ls -la shebangtest.py >> -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py >> [EMAIL PROTECTED]:~/test$ cat shebangtest.py >> #!/usr/bin/python >> >> if __name__ == '__main__': >> >> print "It works" >> [EMAIL PROTECTED]:~/test$ shebangtest >> bash: shebangtest: command not found >> [EMAIL PROTECTED]:~/test$ shebangtest.py >> bash: shebangtest.py: command not found >> >> I've also tried: >> >> #!/usr/bin python >> >> as my shebang line. >> >> I've been unable to get this to work. Clearly, there is something I've >> misunderstood. (`#!' is not an easy thing to google for :-) >> >> Best, >> >> Brian vdB >> > > Your answer lies in the file permission. The file needs to be > executable. If you look at the man pages for chmod, you will find > your answer. > > The shebang line tells the shell what to use to run the script. For > example, if the file is not executable, you would execute it as > follows: > > $ python shebangtest.py > > As you found with `which python`, python is in /usr/bin, so executing > the script is actually > > $ /usr/bin/python shebangtest.py > > Therefore, the shebang line needs to be as follows: > > #! /usr/bin/python > > Then once the script has execute permissions (man chmod), it will run > as expected. > ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] shebang problem
On Sat, Nov 04, 2006 at 06:11:03PM -0600, Brian van den Broek wrote: > Hi all, > > I'm still getting comfortable with Linux and this might be an OS > rather than a python problem. > > I am trying to make a script directly executable. I've reviewed the > 2nd ed of the Nutshell, and I cannot work out what I'm doing wrong. > I'm running ubunutu 6.10 (edgy eft). Here's a copy past of my command > line: > > [EMAIL PROTECTED]:~/test$ which python > /usr/bin/python > [EMAIL PROTECTED]:~/test$ ls -la shebangtest.py > -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py > [EMAIL PROTECTED]:~/test$ cat shebangtest.py > #!/usr/bin/python > > if __name__ == '__main__': > > print "It works" > [EMAIL PROTECTED]:~/test$ shebangtest > bash: shebangtest: command not found > [EMAIL PROTECTED]:~/test$ shebangtest.py > bash: shebangtest.py: command not found Most likely the current directory is not in your path. Type in 'echo $PATH' and look for a single period between colons. It is correct *not* to have the current directory in your path for security reasons. Now type in: './shebangtest' and your program should run. Putting the './' in front tells bash to use the command in the current directory. -- "Rousseau was convinced that God, nature and man were wrong. I know that this opinion still sways many minds, but mine is not one of them." -- Frédéric Bastiat (1801-1850) Rick Pasotto[EMAIL PROTECTED]http://www.niof.net ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] shebang problem
[EMAIL PROTECTED]:~/test$ ls -la shebangtest.py -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py so the file is called shebangtest.py... > [EMAIL PROTECTED]:~/test$ shebangtest > bash: shebangtest: command not found but you try to run shebangtest... bash can't find the file. you didn't put the .py on the end Also you may not have . in your path. For security reasons it isn't there by default. Try [EMAIL PROTECTED]:~/test$ ./shebangtest.py HTH, Alan G. ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
Re: [Tutor] shebang problem
On Sat, November 4, 2006 4:11 pm, Brian van den Broek wrote: > Hi all, > > I'm still getting comfortable with Linux and this might be an OS > rather than a python problem. > > I am trying to make a script directly executable. I've reviewed the > 2nd ed of the Nutshell, and I cannot work out what I'm doing wrong. > I'm running ubunutu 6.10 (edgy eft). Here's a copy past of my command > line: > > [EMAIL PROTECTED]:~/test$ which python > /usr/bin/python > [EMAIL PROTECTED]:~/test$ ls -la shebangtest.py > -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py > [EMAIL PROTECTED]:~/test$ cat shebangtest.py > #!/usr/bin/python > > if __name__ == '__main__': > > print "It works" > [EMAIL PROTECTED]:~/test$ shebangtest > bash: shebangtest: command not found > [EMAIL PROTECTED]:~/test$ shebangtest.py > bash: shebangtest.py: command not found > > I've also tried: > > #!/usr/bin python > > as my shebang line. > > I've been unable to get this to work. Clearly, there is something I've > misunderstood. (`#!' is not an easy thing to google for :-) > > Best, > > Brian vdB > Your answer lies in the file permission. The file needs to be executable. If you look at the man pages for chmod, you will find your answer. The shebang line tells the shell what to use to run the script. For example, if the file is not executable, you would execute it as follows: $ python shebangtest.py As you found with `which python`, python is in /usr/bin, so executing the script is actually $ /usr/bin/python shebangtest.py Therefore, the shebang line needs to be as follows: #! /usr/bin/python Then once the script has execute permissions (man chmod), it will run as expected. -- Carlos Hanson Web and System Administrator Tigard-Tualatin School District 503.431.4053 ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor
[Tutor] shebang problem
Hi all, I'm still getting comfortable with Linux and this might be an OS rather than a python problem. I am trying to make a script directly executable. I've reviewed the 2nd ed of the Nutshell, and I cannot work out what I'm doing wrong. I'm running ubunutu 6.10 (edgy eft). Here's a copy past of my command line: [EMAIL PROTECTED]:~/test$ which python /usr/bin/python [EMAIL PROTECTED]:~/test$ ls -la shebangtest.py -rwxr-xr-- 1 brian brian 68 2006-11-04 02:29 shebangtest.py [EMAIL PROTECTED]:~/test$ cat shebangtest.py #!/usr/bin/python if __name__ == '__main__': print "It works" [EMAIL PROTECTED]:~/test$ shebangtest bash: shebangtest: command not found [EMAIL PROTECTED]:~/test$ shebangtest.py bash: shebangtest.py: command not found I've also tried: #!/usr/bin python as my shebang line. I've been unable to get this to work. Clearly, there is something I've misunderstood. (`#!' is not an easy thing to google for :-) Best, Brian vdB ___ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor