Page 3 of 4

Re: python path

Posted: 3. Feb 2012, 18:36
by gapan
The losuj.py 1st line you posted in the previous page is wrong. There is no /bin/python. It's /usr/bin/python.

Re: python path

Posted: 3. Feb 2012, 18:43
by mimosa
Aha! :idea:

But that still doesn't explain the failure of .losuj-1.py, which calls python correctly. Or does that one work now?

Re: python path

Posted: 3. Feb 2012, 19:22
by ink3
Maybe I would ask about this problem on other forums?
linuxquestions.org?

Re: python path

Posted: 3. Feb 2012, 19:40
by gapan

Code: Select all

$ cd /tmp
$ mkdir mydir
$ cd mydir
$ echo '#!/usr/bin/env python' > mypythonscript
$ echo 'print "It works!"'>> mypythonscript
$ chmod +x mypythonscipt
$ cd
$ PATH=$PATH:/tmp/mydir
$ mypythonscipt
It works!
couldn't be easier than that and no idea where you are getting confused, as you refuse to provide more information. So, yes, go to another forum, expect everyone to be a psychic and you'll magically have your problem solved.

Re: python path

Posted: 3. Feb 2012, 20:28
by ink3
peacefully. I thought you ran out of ideas.
gapan you make typo (mypythonscript) from the 5 row.

don't take offense.

In /tmp path your script works
But in another localization not.
stahoo[skrypty_python]$ echo '#!/usr/bin/env python' > mypythonscript
stahoo[skrypty_python]$ echo 'print "It works!"'>> mypythonscript
stahoo[~]$ chmod +x mypythonscript
stahoo[skrypty_python]$ cd
stahoo[~]$ PATH=$PATH:/home/stahoo/skrypty_python
stahoo[~]$ mypythonscript
bash: /home/stahoo/skrypty_python/mypythonscript: Permission denied
stahoo[~]$

Re: python path

Posted: 3. Feb 2012, 20:46
by Shador
Is the partition mounted with noexec?

Re: python path

Posted: 3. Feb 2012, 20:54
by gapan

Code: Select all

stahoo[skrypty_python]$ echo '#!/usr/bin/env python' > mypythonscript
stahoo[skrypty_python]$ echo 'print "It works!"'>> mypythonscript
stahoo[~]$ chmod +x mypythonscript
Are you aware that you're making ~/mypythonscript executable instead of making ~/skrypty_python/mypythonscript executable?

Re: python path

Posted: 3. Feb 2012, 20:56
by ink3
yes

Code: Select all

$ cat /etc/fstab 
devpts              /dev/pts            devpts         gid=5,mode=620      0         0
proc                /proc               proc           defaults            0         0
tmpfs               /dev/shm            tmpfs          defaults            0         0
/dev/sda2           swap                swap           defaults            0         0
/dev/sda1           /                   ext4           noatime,defaults    1         1
/dev/sda3	/home	ext4	defaults,noexec	1	2

Re: python path

Posted: 3. Feb 2012, 20:57
by mimosa
Please post the output of

Code: Select all

ls -ld /home/stahoo/skrypty_python
mount | grep root
... and as gapan just said, you need to be in the correct directory when issuing the chmod +x, or use an absolute path. I expect that's it!

EDIT

All the King's horses and all the King's men ...

Re: python path

Posted: 3. Feb 2012, 20:58
by Shador
ink3 wrote:yes

Code: Select all

$ cat /etc/fstab 
devpts              /dev/pts            devpts         gid=5,mode=620      0         0
proc                /proc               proc           defaults            0         0
tmpfs               /dev/shm            tmpfs          defaults            0         0
/dev/sda2           swap                swap           defaults            0         0
/dev/sda1           /                   ext4           noatime,defaults    1         1
/dev/sda3	/home	ext4	defaults,noexec	1	2
Well, then don't do it, or you won't be able to execute any program in that location (i.e. remove the ',noexec' part an reboot). I don't think that's a default setting for Salix anywhere.

Edit:
mimosa wrote:... and as gapan just said, you need to be in the correct directory when issuing the chmod +x, or use an absolute path. I expect that's it!
Even if he got the executable permission right, which he probably did, it's definitely the noexec. I already was thinking about that one earlier but it seemed unlikely at that point, as it's nowhere default.