I'm looking some clues or solutions to fix below weird problem.
[sc-d02-087-017:~]$ cat mytest.py
#!/build/toolchain/lin64/python-3.5.1/bin/python
import platform, sys
print(platform.system())
sys.exit(0)
I'm trying to run my test program as shell executable, but shell not recognizing that its a python program that has to interpreted by given /build/toolchain/lin64/python-3.5.1/bin/python, instead throwing err.
[sc-d02-087-017:~]$ ./mytest.py
./mytest.py: line 2: import: command not found
./mytest.py: line 3: syntax error near unexpected token `platform.system'
./mytest.py: line 3: `print(platform.system())'
But this works as expected with python prompt and/or as command line
[sc-d02-087-017:~]$ /build/toolchain/lin64/python-3.5.1/bin/python -c 'import platform, sys;print(platform.system());'
Linux
my machine is 64 arch based
[sc-d02-087-017:~]$ uname -a
Linux sc-d02-087-017 2.6.18-308.8.1.el5 #1 SMP Tue May 29 14:57:25 EDT 2012 x86_64 x86_64 x86_64 GNU/Linux
As requested in the comments:
[sc-d02-087-017:~]$ xxd mytest.py | head
0000000: 2321 2f62 7569 6c64 2f74 6f6f 6c63 6861 #!/build/toolcha
0000010: 696e 2f6c 696e 3634 2f70 7974 686f 6e2d in/lin64/python-
0000020: 332e 352e 312f 6269 6e2f 7079 7468 6f6e 3.5.1/bin/python
0000030: 332e 350a 696d 706f 7274 2070 6c61 7466 3.5.import platf
0000040: 6f72 6d2c 2073 7973 0a70 7269 6e74 2870 orm, sys.print(p
0000050: 6c61 7466 6f72 6d2e 7379 7374 656d 2829 latform.system()
0000060: 290a 7379 732e 6578 6974 2830 290a ).sys.exit(0).
[sc-d02-087-017:~]$ ls -l mytest.py
-rwxr-xr-x 1 mmopuru mts 110 Jun 2 17:23 mytest.py