Python commands on OSS - hp-nonstop

I have extracted the python 2 package in OSS HP Non stop environment with the help of Network team. Does anyone know how to invoke python commands in OSS? If I try OSH it takes me to the Linux environment.
When I try to access python its giving error as
$Data21 APSUSR>Python
No such built in commands, functions.
Thank you in advance.

It looks as though you are trying to run python from the TACL prompt ("$Data21 APSUSER>") - if that is correct then you need to start an OSS shell process first and run python from there. Either use the osh command standalone or logon to an OSS shell rather than a TACL one when you connect to the NonStop.
To answer your question, you should be able to just use python in the normal fashion from the OSS shell prompt:
/home/as: python hello.py
Hello Christie
Remember that OSS is case-sensitive, so you need "python" not "Python".
If the guess about the TACL prompt above is wrong, please cut/paste what you see.
Andy

Related

Why can't I run python scripts from the command line interactive session using "./ name.py"?

I'm following along with Google's Python class, and the person in the videos always runs his scripts from the interactive session in command line using "./". Whenever I try it, I just get a syntax error. How can I use ./ to run scripts? I'm using Windows 10
To run a script from the command line you need to use the syntax
python3 script.py
Now on Unix systems, it's possible to add a shebang to the first line of the script as followings
#!/usr/bin/env python3
This then allows the shell syntax './name.py' to work. But windows doesn't have this mechanism. Instead, you need to create an 'association' between the .py extension and the python executable ('right click', 'open with'). Or just use the full syntax. Both require the python executable to be in your path, and generally on windows both python 2 and 3 will have the same executable name

Termux says "'Bad Interpreter: No such file or directory"

I have a problem and hope someone can help me. I am currently trying to write a script for Termux or Termux:Task. My script currently looks like this:
#!/data/data/com.termux/files/usr/bin/bash
cd /./sdcard/www/public/
wp post list sleep 5
Every time I load the script I get the following error message:
/data/data/com.termux/files/usr/bin/wp: /usr/bin/env: bad interpreter: No such file or directory.
I've been looking for a solution to my problem for hours, unfortunately without success.
I am using an extension for Termux called "WordPress CLI". When I start termux and enter the commands individually, everything works. But as soon as I write the commands into a sh script and start it doesn't work anymore. :(
Can anyone help me?
Thanks a lot
This is simple error you can fix it by replacing !/data/data/com.termux/files/usr/bin/bash. With #!/data/data/com.termux/files/usr/bin/bash
Please tell if you get error again
Try with #!/usr/bin/env bash in the shebang line.
Termux-exec allows you to execute scripts with shebangs for traditional Unix file structures. So shebangs like #!/bin/sh and #!/usr/bin/env python should be able to run without termux-fix-shebang.
From https://wiki.termux.com/wiki/Termux-exec
According to doc:
Why do I keep getting a '/bin/sh bad interpreter' error?
This error is thrown due to access script interpreter at nonexistent
location.
Termux does not have common directories like /bin, /sbin, /usr/bin at
their standard place. There is an exception for certain devices where
/bin is a symbolic link to /system/bin, but that does not make a
difference.
Interpreters should be accessed at this directory only:
/data/data/com.termux/files/usr/bin
There are three ways to fix this:
Install termux-exec by using pkg install termux-exec. It won’t affect the current session, but after a restart should work without
any setup. Not needed if your Termux is up to date. If still not
working, try the next workaround.
Use command termux-fix-shebang to fix the shebang line of specified file.
Use termux-chroot from package proot to setup a chroot environment mimicking a normal Linux file system in Termux.
termux-fix-shebang my_script.py of second method work for me, which it modify the shebang(first line of my_script.py) from #!/usr/bin/env python to #!/data/data/com.termux/files/usr/bin/env python. Since /usr/bin/ is not exist in Android, that's why it throws the error /usr/bin/env: bad interpreter: No such file or directory. The other solution is run with python my_script.py, neither of my_script.py nor ./my_script.py.
In my test, termux-exec of the first method only work if I added correct shebang in main script(child OR child of child script no need) and ran command export LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so.
And for the issue of this question, error shows /usr/bin/env in the middle with /data/data/com.termux/files/usr/bin/wp even though the shebang of script #!/data/data/com.termux/files/usr/bin/bash looks ok, it means that wp command (located at /data/data/com.termux/files/usr/bin/wp) used inside the script contains shebang #!/usr/bin/env wp and should modify it to #!/data/data/com.termux/files/usr/bin/env wp too. termux-exec of first method should fix this specific case too(already has correct shebang in main script).

Running a python script in windows

I am new to Python.
I am executing a script in windows, but it does nothing and gives an error "invalid syntax".
Can you help me with the error. I have set the PATH variable to include my python.exe location.
Please see attached image:
Your image is from the python command line, only python commands are accepted there and there is no need to specify python in the beginning (in the shell python is just a call to the python interpeter).
In order to run windows commands in python use the os or subprocess modules.

python not accessible in powershell v3 when opened with Popen

Hopefully this should be simple. Python environment is running fine if I open PowerShell v3 manually. I can check version and run external scripts etc. But as soon as I open powershell.exe through subprocess.Popen from a python script from another application, python simply won't run; "The term 'Python' is not recognised as the name of a cmdlet, function, script file or operable program... etc"
I've checked my environment paths repeatedly and python is running fine on the system in general.
anyone has any idea what this could be caused by?
subprocess.Popen(["powershell.exe", '-ExecutionPolicy', 'RemoteSigned', "path to PS1_script_with python command"])
My PS1 file looks like this:
cd C:\Users\David\Geeknote\geeknote-master\geeknote
python gnsync.py --path "C:\Users\David\Desktop\C4DtoEvernote", --mask "*.nfo", --notebook "Python Logs"
function Pause{Read-Host 'You have successfully synced your C4D Annotations to Evernote using gnsync.
Please press Enter to continue...' | Out-Null}
Pause{}
It seems (for whatever reason) your $PATH is not being read or honored by the process; and thus python cannot be found.
You can either:
Set up the path with $env:Path = "C:\Python27:C:\Python27\Scripts";
Setup the path using a custom console profile (ie, a .ps1 file) and passing it with -PSConsoleFile.
The simplest option, pass the full path to the Python executable in your command file C:\Python27\python.exe gsync.py ...
I would try #3, and then see if you need the other options.
Adjust the paths as appropriate - especially if you have multiple Python interpreters installed.

Python script.py once saved now won't load as before

I have just started looking & learning Python (on Ubuntu 14.04) using the website: http://learnpythonthehardway.org/book/ and http://www.codecademy.com/
Yesterday, I worked for an hour on a few scripts namely 1-4 and named them as ex1.py etc and they executed fine. Today, I have come back to carry on with a few more exercises and tested my first exercises only to find now I get "SyntaxError: invalid syntax" when attempting "python ex1.py" with or without .py I have tried "#!/usr/bin/python" in any script header also. The path/Dir I have been using to test my Python scripts in is simply 'Python' within my Home Dir. I checked the actual file permissions but that appears to make no difference.
I am not too sure if it's an OS setup issue; Python issue; or simply me. Python seems great, so any ideas on what I'm doing wrong? What has changed since yesterday to my python.py script files?
The problem is that you are in the Python interpreter, and not the Linux terminal. This is indicated both by the error messages you saw and by the >>> prompt.
Exit the interpreter by holding down control and pressing the D key. You will then be back in the Linux terminal and running a script will work the way you expect it to.