I have created this executable out of a python script. All it does is prints 'Hello World'. I am trying to run this off SQLPlus.
My SQlPlus query is as provided below:
START 'C:\USERS\ADMINISTRATOR\DESKTOP\dist\HW.exe'
I keep getting the following error:
Using 'Host', gives:
Any help/suggestion/edits would be appreciated.
I have also plainly tried to run the python script 'HW.py' resulting in the following error:
What is the right way to execute the HW.exe from SQLPlus?
Related
uwsgi + Python subprocess
Hello everyone,
I am trying to run a simple command in shell using Python subprocess module, everything works fine till I put
uwsgi on the top. I also use flask as web framework.
Here is very simplified part of the code
if request.method == 'POST':
testquery = subprocess.run( "ifconfig", shell=True,stdout=subprocess.PIPE,universal_newlines=True )
whoisresults=whoisquery.stdout
print(whoisresults)
I was getting following error : /bin/sh: 1: ifconfig: not found
I replaced "ifconfig" with the full path where Python virtual evn runs.
testquery = subprocess.run( "/home/net/netools/netoolsenv/bin ifconfig", shell=True,stdout=subprocess.PIPE,universal_newlines=True )
whoisresults=whoisquery.stdout
print(whoisresults)
But it still does not work, just error is different - /bin/sh: 1: /home/net/netools/netoolsenv/bin: Permission denied
Can anyone please advice in what direction should I dig? I am beginner here.
I was getting following error : /bin/sh: 1: ifconfig: not found
uWSGI daemon usually run as another user, and this user has no PATH set. Use full absolute path to ifconfig.
To find full path to your tools, use which, e.g. run this command at your terminal:
$ which ifconfig
/usr/bin/ifconfig
and use that full path to ifconfig in your Python script.
testquery = subprocess.run( "/usr/bin/ifconfig", shell=True,stdout=subprocess.PIPE,universal_newlines=True )
How to Pass a Terminal error into the Python program whenever the error is triggered in the terminal?
Example:
Consider I'm running a java program and I get some error like this
file.java:2: error: ',', ')', or '[' expected
public static void main(String args...) {
^
1 error
Another example by entering the wrong bash command
ls: option '--a' is ambiguous; possibilities: '--all' '--almost-all' '--author'
Try 'ls --help' for more information.
I need to pass this error to a python program and run the program whenever the terminal shows the error like this.
How can I pass the error?
I've seen a few posts on this topic with odd hard to reproduce behaviours. Here's a new set of data points.
Currently the following works
cd ./hosts
./ec2.py --profile=dev
And this fails
AWS_PROFILE=dev; ansible-playbook test.yml
These were both working a couple days ago. Something in my environment changed. Still investigating. Any guesses?
Error message:
ERROR! The file ./hosts/ec2.py is marked as executable, but failed to execute correctly. If this is not supposed to be an executable script, correct this withchmod -x ./hosts/ec2.py.
ERROR! Inventory script (./hosts/ec2.py) had an execution error: ERROR: "Error connecting to AWS backend.
You are not authorized to perform this operation.", while: getting EC2 instances
ERROR! ./hosts/ec2.py:3: Error parsing host definition ''''': No closing quotation
Note that the normal credentials error is:
ERROR: "Error connecting to AWS backend.
You are not authorized to perform this operation.", while: getting EC2 instances
...
Hmmm. Error message has shifted.
AWS_PROFILE=dev; ansible-playbook test.yml
ERROR! ERROR! ./hosts/tmp:2: Expected key=value host variable assignment, got: {
Looks like the problem was a temporary file in the hosts folder. After removing it the problems went away. It looks like std ansible behaviour: Pull in ALL files in the hosts folder.
In python I am trying to execute a fabfile and ,I get the below error from the subproccess output. I installed fabric using easy install. If I run the code from the command line it works. From python no go. I assume there is an issue with how I am using the Popen command?
/bin/sh: 1: fab: not found
Below is how I start fabric from python:
cmd = """fab -H 111.111.111.111 aws_bootstrap initial_chef_run:aws_server.json,aws-test,development -w """
os.chdir(fab_path) #change to the dir where the fabfile is located
p = subprocess.Popen(cmd, shell=True,stderr=subprocess.STDOUT,stdout=subprocess.PIPE)
PS I added the below to the Popen but get the below error:
executable="/bin/bash"
/bin/bash: fab: command not found
From the command line I get the below which means the terminal can find fab.
fab
Fatal error: Couldn't find any fabfiles!
Remember that -f can be used to specify fabfile path, and use -h for help.
Aborting.
Try to use the whole path for fab. To get the path to fab on your system, you can use which fab.
However, I can't think of any reason why calling fab from python might be better than using the execute function of fab:
from fabric.tasks import execute
import my_fabfile
r = execute(my_fabfile.aws_bootstrap, hosts=["root#%s" % '111.111.111.111])
Return value r will contain a dict with the hosts as key(s).
I have a file: test.py
Permissions on this file are set to 777, I am attempting to run the following script:
#!/usr/lib/python2.7
print("Content-Type: text/html\n")
print("test")
I receive the following error:
The server encountered an internal error and was unable to complete your request.
Error message:
End of script output before headers: test.py
If you think this is a server error, please contact the webmaster.
Error 500
Python is installed:
$ python --version
>> Python 2.7.4
Solved the problem, you need to use the location of the python interpreter in the first line of the code which can be found by running the following script in the python interpreter (can be invoked by typing python into the terminal):
import sys; sys.executable;