[Pythonmac-SIG] python script execution strangeness

Mario Ruggier mario@ruggier.org
Sat, 5 Apr 2003 09:27:54 +0200


Hi,

running scripts from the command-line is behaving very strangely
on my 10.2.4 system, and only one-liner scripts seem to be executed
as expected. Below are an interactive session, followed by a few script
examples (using '---' to visually indicate end-of-file), and their 
output.
Whenever the python script contains more than one line, an error is
reported. Plus, when I stick "#!/usr/bin/python" at the beginning of the
script (one or more lines), no output (and no error) is generated.

Anyone has an idea what's going on?

Thanks for any help,

	Mario


% python
Python 2.2 (#1, 07/14/02, 23:25:09)
[GCC Apple cpp-precomp 6.14] on darwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> print 'something'
something
 >>>^D
%

======================= [testscript.py]
print 'something'---
%python testscript.py
something
%

======================= [testscript.py]
print 'something'
---
%python testscript.py
something
%

======================= [testscript.py]
print 'something'
print 'something else'
---
%python testscript.py
   File "<string>", line 1
print 'something else'
                      ^
SyntaxError: invalid syntax
%

======================= [testscript.py]
print 'something'; print 'something else';
---
% python testscript.py
something
something else
%

======================= [testscript.py]
print 'something'

---
%python testscript.py
   File "<string>", line 1
     print 'something'
                      ^
SyntaxError: invalid syntax
%

======================= [testscript.py]
#!/usr/bin/python
print 'something'
---
%python testscript.py
%

=======================