Hi,
sorry, my english ist not that got but I'll try.
I have a running python script (capisuit incoming.py). This script shall
start a linux shell script. If I start this script like os.system(/paht/to
shellscipt.sh) the python scipt waits for the exit of the shell script and
then goes on with the rest of the python script.
How to start a shell script without waiting for the exit of that shell
script? It shall start the shell script and immediately execute the next
python command.
Thanks for any hints
Erik
--
Jemanden wie ein rohes Ei zu behandeln kann auch bedeuten, ihn in die Pfanne
zu hauen. 9 1979
Quickie:
os.system("/path/to/script.sh &")
More elegant, have a look at threads
------------
Harlin Seritt
Erik Geiger wrote: Hi,
sorry, my english ist not that got but I'll try.
I have a running python script (capisuit incoming.py). This script shall start a linux shell script. If I start this script like os.system(/paht/to shellscipt.sh) the python scipt waits for the exit of the shell script and then goes on with the rest of the python script.
How to start a shell script without waiting for the exit of that shell script? It shall start the shell script and immediately execute the next python command.
Thanks for any hints
Erik
See the os. spawn* functions. For example
os.spawnv(os.P_ NOWAIT, /path/to/script, args)
/Jean Brouwers
In article <cq**********@o nline.de>, Erik Geiger <Er*********@gm x.de>
wrote: Hi,
sorry, my english ist not that got but I'll try.
I have a running python script (capisuit incoming.py). This script shall start a linux shell script. If I start this script like os.system(/paht/to shellscipt.sh) the python scipt waits for the exit of the shell script and then goes on with the rest of the python script.
How to start a shell script without waiting for the exit of that shell script? It shall start the shell script and immediately execute the next python command.
Thanks for any hints
Erik
Erik Geiger wrote: I have a running python script (capisuit incoming.py). This script shall start a linux shell script. If I start this script like os.system(/paht/to shellscipt.sh) the python scipt waits for the exit of the shell script and then goes on with the rest of the python script.
How to start a shell script without waiting for the exit of that shell script? It shall start the shell script and immediately execute the next python command.
if you have Python 2.4, you can use the subprocess module: http://docs.python.org/lib/module-subprocess.html
see the spawn(P_NOWAIT) example for how to use it in your
case: http://docs.python.org/lib/node236.html
as others have noted, os.spawn(P_NOWA IT) can be used directly, as
can os.system("comm and&") (where the trailing "&" tells the shell to run
the command in the background).
subprocess is available for Python 2.2 and 2.3 as well, by the way: http://www.lysator.liu.se/~astrand/popen5/
</F>
Fredrik Lundh schrieb: Erik Geiger wrote:
[...] How to start a shell script without waiting for the exit of that shell script? It shall start the shell script and immediately execute the next python command.
if you have Python 2.4, you can use the subprocess module:
http://docs.python.org/lib/module-subprocess.html
see the spawn(P_NOWAIT) example for how to use it in your case:
http://docs.python.org/lib/node236.html
Thats what I've tried, but it did not work. Maybe it's because I want to
start something like su -c '/path/to/skript $parameter1 $parameter2' user
I don't understand the syntax of spawn os.spawnlp(os.P _NOWAIT, "/path/to
script", "the script again?", "the args for the script?") as others have noted, os.spawn(P_NOWA IT) can be used directly, as can os.system("comm and&") (where the trailing "&" tells the shell to run the command in the background).
Thats what I've used in the Shellscript, but I haven't realized how to use
it in thy python script, thanks! :) subprocess is available for Python 2.2 and 2.3 as well, by the way:
http://www.lysator.liu.se/~astrand/popen5/
</F>
Erik
--
Jemanden wie ein rohes Ei zu behandeln kann auch bedeuten, ihn in die Pfanne
zu hauen.
Jean Brouwers schrieb:
See the os. spawn* functions. For example
os.spawnv(os.P_ NOWAIT, /path/to/script, args)
/Jean Brouwers
Thats what I've tried, but failed.
Thanks anyway ;-)
Greets
Erik
[...]
--
Jemanden wie ein rohes Ei zu behandeln kann auch bedeuten, ihn in die Pfanne
zu hauen.
Thanks, thats what I use now :)
Harlin Seritt schrieb: Quickie:
os.system("/path/to/script.sh &")
More elegant, have a look at threads
------------ Harlin Seritt
Erik Geiger wrote:
Hi,
sorry, my english ist not that got but I'll try.
I have a running python script (capisuit incoming.py). This script shall start a linux shell script. If I start this script like os.system(/paht/to shellscipt.sh) the python scipt waits for the exit of the shell script and then goes on with the rest of the python script.
How to start a shell script without waiting for the exit of that shell script? It shall start the shell script and immediately execute the next python command.
Thanks for any hints
Erik
--
Jemanden wie ein rohes Ei zu behandeln kann auch bedeuten, ihn in die Pfanne
zu hauen.
In article <cq**********@o nline.de>, Erik Geiger <Er*********@gm x.de>
wrote: Fredrik Lundh schrieb:
Erik Geiger wrote: [...] How to start a shell script without waiting for the exit of that shell script? It shall start the shell script and immediately execute the next python command.
if you have Python 2.4, you can use the subprocess module:
http://docs.python.org/lib/module-subprocess.html
see the spawn(P_NOWAIT) example for how to use it in your case:
http://docs.python.org/lib/node236.html
Thats what I've tried, but it did not work. Maybe it's because I want to start something like su -c '/path/to/skript $parameter1 $parameter2' user I don't understand the syntax of spawn os.spawnlp(os.P _NOWAIT, "/path/to script", "the script again?", "the args for the script?")
Unfortunately this particular case kind of dilutes the advantages
of spawnv. In the common case, parameter1 et al. would be submitted
directly as the parameter list. I believe it may be clearer to start
with to think about the spawnv() function -
os.spawnv(os.P_ NOWAIT, path, [cmdname, parameter1, parameter2])
If one of the parameters is itself another command, then of course
it has to be rendered as a string
os.spawnv(os.P_ NOWAIT, '/bin/su', ['su', '-c', '%s %s %s' % (cmd,
parameter1, parameter2)])
so you have almost as much work to scan the parameters for shell
metacharacters as you would have with system().
Donn Cave, do**@u.washingt on.edu
Donn Cave schrieb: In article <cq**********@o nline.de>, Erik Geiger <Er*********@gm x.de> wrote:
[...] Thats what I've tried, but it did not work. Maybe it's because I want to start something like su -c '/path/to/skript $parameter1 $parameter2' user
Unfortunately this particular case kind of dilutes the advantages of spawnv. In the common case, parameter1 et al. would be submitted directly as the parameter list. I believe it may be clearer to start with to think about the spawnv() function - os.spawnv(os.P_ NOWAIT, path, [cmdname, parameter1, parameter2])
If one of the parameters is itself another command, then of course it has to be rendered as a string os.spawnv(os.P_ NOWAIT, '/bin/su', ['su', '-c', '%s %s %s' % (cmd, parameter1, parameter2)]) so you have almost as much work to scan the parameters for shell metacharacters as you would have with system().
Donn Cave, do**@u.washingt on.edu
OK, thats too high for me ;-)
Is the %s the variable for the following commands/parameters? If I have
three parameters, I'll need one more %s? Where to write the user for the su
command?
Well, I've given up ;-)
Thanks for the explanation!
Erik
--
Jemanden wie ein rohes Ei zu behandeln kann auch bedeuten, ihn in die Pfanne
zu hauen.
On 2004-12-22, Erik Geiger <Er*********@gm x.de> wrote: Donn Cave schrieb:
In article <cq**********@o nline.de>, Erik Geiger <Er*********@gm x.de> wrote: [...] > Thats what I've tried, but it did not work. Maybe it's because I want to > start something like su -c '/path/to/skript $parameter1 $parameter2' > user
Unfortunately this particular case kind of dilutes the advantages of spawnv. In the common case, parameter1 et al. would be submitted directly as the parameter list. I believe it may be clearer to start with to think about the spawnv() function - os.spawnv(os.P_ NOWAIT, path, [cmdname, parameter1, parameter2])
If one of the parameters is itself another command, then of course it has to be rendered as a string os.spawnv(os.P_ NOWAIT, '/bin/su', ['su', '-c', '%s %s %s' % (cmd, parameter1, parameter2)]) so you have almost as much work to scan the parameters for shell metacharacters as you would have with system().
Donn Cave, do**@u.washingt on.edu OK, thats too high for me ;-)
Is the %s the variable for the following commands/parameters? If I have three parameters, I'll need one more %s? Where to write the user for the su command?
Well, I've given up ;-)
Hey, don't give up. There is help. ;-) guess...
There is a package called pyNMS ( http://sourceforge.net/projects/pynms)
That has a module called "proctools" , and also one called "sudo". Once
you set up sudo correctly, you can do what you want easily.
However, be aware that proctools spawns a process with the subprocess
stdio connected to _your_ parent process, and does not inherit the stdio
of the parent. So, if the subprocess writes a lot of stuff you must read
it, or the subprocess will block. However, there is some (perhaps buggy)
support for asynchronous operation where those reads happen
automatically (on Linux).
--
-- ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~
Keith Dart <kd***@kdart.co m>
public key: ID: F3D288E4
=============== =============== =============== =============== ========= This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mark Adams |
last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail
server running for several months. It took me a week or so to get it up
and running in September. Now, I did a clean upgrade to Mandrake 9.2
and am reinstalling everything. This thing is kicking my ass and I
can't seem to get past it. I could really use some help if anybody has any.
Just for reference, this was my primary source for information on
installation and...
|
by: Mark Adams |
last post by:
I am a relative newbie to MySQL. I had a Postfix+Courier+MySQL mail
server running for several months. It took me a week or so to get it up
and running in September. Now, I did a clean upgrade to Mandrake 9.2
and am reinstalling everything. This thing is kicking my ass and I
can't seem to get past it. I could really use some help if anybody has any.
Just for reference, this was my primary source for information on
installation and...
|
by: Marc |
last post by:
I want to write a C#/ASP.NET application where a user can go to a web page, start running a job, close their browser, and then come back later and see the results. The purpose for this application is for a user to be able to use a page on our intranet to start running a time-consuming reporting and analysis job. I'm not sure how to start a process in ASP.NET and then "detach" it, or how to check that it's still running later. I think that maybe...
|
by: Dmitri Shvetsov |
last post by:
Hi,
Can I start an external process from the Web Service?
I'm using a code, compiler keeps silence, compiles ok and starts the
project. When I trace in Debugger it doesn't start an external process.
That's strange for me. I understand that it should be a new shell, but why I
can't start it? Is it need to have a Windows application to start an
external process? I created a very long batch files and a complicated
script to work with...
|
by: Marc |
last post by:
I want to write a C#/ASP.NET application where a user can go to a web page, start running a job, close their browser, and then come back later and see the results. The purpose for this application is for a user to be able to use a page on our intranet to start running a time-consuming reporting and analysis job. I'm not sure how to start a process in ASP.NET and then "detach" it, or how to check that it's still running later. I think that maybe...
| |
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |