Hi -- sorry for not searching first, but I get an NNTP error from
netscape (a known bug, still looking for workaround).
Inside a python script, I want to execute a UNIX command and
send the output to a Python string, returning the shell return
code value as an integer or exception.
I'm sure I could write a function using pipes and whatnot, but
I'm hoping this is a solved problem by now, more elegantly and
correctly coded than my hack job would be.
Thanks,
Jeff
Python rocks, btw. I've almost broken the #!/bin/ksh habit ;) 2 2321
Check out: http://www.python.org/doc/current/li...-commands.html
It's Unix-specific, but I guess you did say "Unix command"...
-Rick Ratzel
Jeff Learman wrote: Hi -- sorry for not searching first, but I get an NNTP error from netscape (a known bug, still looking for workaround).
Inside a python script, I want to execute a UNIX command and send the output to a Python string, returning the shell return code value as an integer or exception.
I'm sure I could write a function using pipes and whatnot, but I'm hoping this is a solved problem by now, more elegantly and correctly coded than my hack job would be.
Thanks, Jeff
Python rocks, btw. I've almost broken the #!/bin/ksh habit ;)
Thanks! Just what I was looking for ... don't know why I didn't
see it in the docs.
Rick L. Ratzel wrote: Check out:
http://www.python.org/doc/current/li...-commands.html
It's Unix-specific, but I guess you did say "Unix command"...
-Rick Ratzel
Jeff Learman wrote:
Hi -- sorry for not searching first, but I get an NNTP error from netscape (a known bug, still looking for workaround).
Inside a python script, I want to execute a UNIX command and send the output to a Python string, returning the shell return code value as an integer or exception.
I'm sure I could write a function using pipes and whatnot, but I'm hoping this is a solved problem by now, more elegantly and correctly coded than my hack job would be.
Thanks, Jeff
Python rocks, btw. I've almost broken the #!/bin/ksh habit ;)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: jelle |
last post by:
Hi,
I use python quite a bit to couple different programs together.
Doing so has been a _lot_ easier since subprocess came around, but
would really like to be able to use the succinct shell...
|
by: A.M |
last post by:
Hi,
I am having difficulty with shell scripting in Python.
I use the following command to run a DOS command and put the return value in
a Python variable:
|
by: Gerard Flanagan |
last post by:
Hello,
I have a third party shell script which updates multiple environment
values, and I want to investigate (and ultimately capture to python)
the environment state after the script has run....
|
by: George Sakkis |
last post by:
I'm trying to figure out why Popen captures the stderr of a specific
command when it runs through the shell but not without it. IOW:
cmd =
if 1: # this captures both stdout and stderr as...
|
by: koutoo |
last post by:
Is it possible to display messages in the python shell? I want to
display error messages based on parameters in my scripts to the
users. Is there another way to display messages other than log...
|
by: raocheng |
last post by:
Please see the following code.
Suppose I have many shell commands to be executed. And I don't want to
fork a sub shell for each command(eg: status,output =
commands.getstatusoutput(cmd)) because...
|
by: ellipsism |
last post by:
Hello,
I'm using VBA from Excel to call a python script with some arguments. The python script returns only true or false, which is the information I want to take back into Excel.
I'm wondering,...
|
by: Samuel A. Falvo II |
last post by:
I have a shell script script.sh that launches a Java process in the
background using the &-operator, like so:
#!/bin/bash
java ... arguments here ... &
In my Python code, I want to invoke...
|
by: devi thapa |
last post by:
Hi,
I am executing a python script in a shell script. The python script
actually returns a value.
So, can I get the return value in a shell script? If yes, then help me out.
Regards,
Devi
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |