Problems compiling python

  • Thread starter Florian Lindner
  • Start date
F

Florian Lindner

Hello,
I want to compile that small python script:

bastet:/ # cat test.py
#!/usr/bin/python
import sys, os
username = os.getlogin()
print username
os.spawnv(os.P_WAIT, "/root/mailboxmgm.py", sys.argv)

Python 2.3.2 (#1, Oct 12 2003, 14:27:24)
[GCC 3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.bastet:/ # chmod u+x test.pyc
bastet:/ # ./test.pyc
../test.pyc: line 1: syntax error near unexpected token `;'
'/test.pyc: line 1: `;ò
bastet:/ #

What is wrong?

Thanks,
Florian
 
E

Erik Max Francis

Florian said:
I want to compile that small python script: ...
bastet:/ # chmod u+x test.pyc
bastet:/ # ./test.pyc
./test.pyc: line 1: syntax error near unexpected token `;'
'/test.pyc: line 1: `;ò
bastet:/ #

What is wrong?

A compiled Python file (.pyc) is not an executable. (Specifically, in
the Unix world, it does not contain a bangpath.) Instead, just pass it
as an argument to the Python interpreter:

max@oxygen:~/tmp% cat > hello.py
print "Hello, world!"
^D
max@oxygen:~/tmp% python
Python 2.3.3 (#1, Dec 22 2003, 23:44:26)
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.max@oxygen:~/tmp% ls hello.py*
hello.py hello.pyc
max@oxygen:~/tmp% rm hello.py
max@oxygen:~/tmp% python hello.pyc
Hello, world!
 
F

Florian Lindner

Erik said:
Florian said:
I want to compile that small python script: ...
bastet:/ # chmod u+x test.pyc
bastet:/ # ./test.pyc
./test.pyc: line 1: syntax error near unexpected token `;'
'/test.pyc: line 1: `;ò
bastet:/ #

What is wrong?

A compiled Python file (.pyc) is not an executable. (Specifically, in
the Unix world, it does not contain a bangpath.) Instead, just pass it
as an argument to the Python interpreter:

max@oxygen:~/tmp% cat > hello.py
print "Hello, world!"
^D
max@oxygen:~/tmp% python
Python 2.3.3 (#1, Dec 22 2003, 23:44:26)
[GCC 3.2.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.max@oxygen:~/tmp% ls hello.py*
hello.py hello.pyc
max@oxygen:~/tmp% rm hello.py
max@oxygen:~/tmp% python hello.pyc
Hello, world!

Can I run these scripts under another UID than the user executing them?
(SUID)

Thx,
Florian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,174
Messages
2,570,940
Members
47,486
Latest member
websterztechnologies01

Latest Threads

Top