f



How do I get the process id when starting a process using os.popen2 or os.popen3 on linux?

Is there a way to get the process id when starting a process using
os.popen2 or os.popen3 on linux?

Mike

0
mikem76 (3)
6/7/2006 10:05:34 PM
comp.lang.python 77058 articles. 6 followers. Post Follow

1 Replies
991 Views

Similar Articles

[PageSpeed] 41

mikem76@gmail.com wrote:

> Is there a way to get the process id when starting a process using
> os.popen2 or os.popen3 on linux?

on Unix, os.popen2/popen3 uses functions and classes from the popen2 
module.  they return file objects attached to the process, but there's
no (non-hacky) way to get at the process itself.

if you need more control over the subprocess, you can use the classes in 
the popen2 module, or, better, the subprocess module.

</F>

0
fredrik2101 (5275)
6/7/2006 10:27:02 PM
Reply:

Similar Artilces:

Getting process id of started process
Say I want to start a long running shell process (and monitor that process). def start_process @process_id = fork do Kernel.system "cat /dev/zero > /dev/null" end end However, @process_id doesn't contain the pid of the cat process. How can I capture the pid of that process? Thanks, Joe I've attatched code and test code at http://rafb.net/paste/results/2Rj4rb87.html , if someone wants to take a look. Hopefully it's clear about what I want to do. On Wed, 30 Mar 2005 14:57:51 -0800, Joe Van Dyk <joevandyk@gmail.com> wro...

why does id(multiprocessing.Process.start) == id(multiprocessing.Process.start)?
using Python 2.7.9, I get the following: >>> id(multiprocessing.Process.start) == id(multiprocessing.Process.start) True But on the other hand: >>> multiprocessing.Process.start is multiprocessing.Process.start False I thought that these two expressions were equivalent. Can somebody help me to understand what's going on here? On Monday, August 17, 2015 at 3:24:22 PM UTC-7, alex....@gmail.com wrote: > using Python 2.7.9, I get the following: > > >>> id(multiprocessing.Process.start) == id(multiprocessing.Process.start) > True >...

Linux inotify
Hi I'm currently learning to use the Linux inotify subsystem API which allows a program to be notified of file system changes/accesses etc. However , while it'll tell you what files or directories have had something done to them there doesn't appear to be a way to tell you what process actually did it. ie: its all very well knowing that file /dev/foo/bar has just been moved to another location but it would be nice to know what process did the moving. Is there a way to obtain this information or is it not provided because a lot of the processes will be ephemeral (eg mv) and the ...

problem while starting a process which is using DLL when being called using the create process
Error is as follows :- Runtime Error 429 : ActiveX component cannot create object OS: Win NT 4, VB-6.0 I have a custom made dll Project A spawns the Project B exe file through CreateProcess. Project B is using the dll. Error 429 comes on this line CreateProcess. ProjectB runs fine independently. We have also tried using Shell for spawning the process but same error. We also tried unregistering and registering the dll . Pls help. ...

Getting the process ID of a new process
HI, If you have script which starts 5 instances of a program, how to get the process ID of these 5 programs? All I know is the the scripts ID is $$! /michael On Wed, 15 Sep 2004, Michael Laajanen wrote: > If you have script which starts 5 instances of a program, how to get the > process ID of these 5 programs? > > All I know is the the scripts ID is $$! It might depend on the shell and/or the revision of Solaris. The sh man page on Solaris 10 says that $! is the "process number of the last background command invoked". Sounds like what you want... -- Rich Teer, ...

get process name from process id
I need to know the name of the parent process. using getppid function I can get the process id of the parent process. How do I translate parent pid to a name. Is there a way to do it in in perl without invoking ps command. thanks. perlcoder <a@a.com> writes: > I need to know the name of the parent process. > using getppid function I can get the process id > of the parent process. How do I translate parent > pid to a name. > > Is there a way to do it in in perl without invoking ps command. From what I've been able to find in a few minutes of searching, you...

to get the process name from Process ID
How can I get the process name from Process ID with a Basic function? (under WinXP) Here's a link for an example that enumerates and lists all running processes: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com: 80/support/kb/articles/Q187/9/13.asp&NoWebContent=1 Although the EnumProcesses API is only found on NT 4 and later, this example handles earlier versions of Winders as well. If you're only concerned about XP, then you probably can eliminate a bunch of code from the example (the stuff for Win98/ME). But basically, what you'd want to do is ...

Getting the process name by giving the process id.
Hi!. Can anybody tell me how I can get the process name from the proces id in Windows 98 / Windows ME. At present I am able to get the process name by using the win api toolhelp functions. But the toolhelp functions give me a snap shot of all the processes running in the system and I have to loop through all the processes till I find process having the process id i want. But in win Nt I need not have to loop through the processes and the process modules of the process to get the process name as I have the EnumProcessModules method and GetModuleFileNameEx method. I want to know if the...

Getting the name of the process via the process ID
Is there a way that is OS independent (that is, works the same way on Windows and all the various flavors of Unix) to get the name of a process from the process ID? I know about the Proc-ProcessTable module, but that apparently doesn't work on Windows. And yes, I also know about using the system command to run "ps" (or to use open(PS, "ps|"), and that you can get a Windows "ps" command, but I'd rather get something with a more standard interface. -- David ...

Start-up processes in OS X
I stumbled across a way to kill processes that run automatically at start up (like the "Comcast Wizard") but I cannot for the life of me remember what it was. I know it was part of OS X, but that is about it. Can anyone jog my dust memory? ...

Capturing the Process ID of a Process started in Background in ksh
I have a need to create a menu program using ksh where I am able to tail some logs and kill the tail in the same window by typing some keyword as interrupt. So, I say ******************************************** tail -f ongoingprocess.log & PROCESS_ID=$! echo "PROCESS_ID: " ${PROCESS_ID} ******************************************** When I run the above ksh script, the output I get is: PROCESS ID: 2433 However, when I run "ps -eaf | grep 'tail -f ongoingprocess.log' ", I get the following: gaajulc 2432 2400 0 13:18:31 pts/41 0:00 tail -f ongoinglog...

Launching a process (exe) using the same process id as the launcher
Launching a process (exe) using the same process id as the launcher, how is it possible ? I want my VCStudio to launch my executable (which is not in developpement) and this exe will launch the exe module I am currently developping with the correct arguments, I want to debug it not the wrapper that launched it VCStudio starts as debug --> A which starts --> B which loads --> C.dll which I want to debug How can B have the same process id as A ?? or How can I make VCStudio attach to B without doing it manualy ? thanx On Fri, 04 Jul 2008 00:02:51 +0200, franckspike <franckspike@...

os.path.split: processing paths from one OS on another
Heya folks, I ran into the following problem: When i run this on Windows everything is as expected: C:\>python Python 2.2.3 (#42, May 30 2003, 18:12:08) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> file='/TEST/FILE.EXT' >>> print os.path.split(file) ('/TEST', 'FILE.EXT') >>> file='C:\\TEST\\FILE.EXT' >>> print os.path.split(file) ('C:\\TEST', 'FILE.EXT') However, when i run this ...

How can get process id of a process running on remote machine.
Hi, I have run a process on remote machine with system() call using "ssh abc@host './process'". Process is up and running on remote machine. Is there any way i can find PID of a process running in remote machine. I couldnt do that with system("ps -aef | grep process | awk....."), since we can't get output of a command run using system() call. Can any one help? Thnx in advance, Sandeep On Nov 22, 8:33 am, sandy <rayapudisand...@gmail.com> wrote: > Hi, > > I have run a process on remote machine with system() call using "ssh > abc@host ...

how to pause the sleep process when the OS already enter into sleep process
I need to do something when the OS is going to sleep. when the app received PBT_APMSUSPEND message, I will begin to do my job. But sometimes OS will suspend completedly before I complete my job. how to ensure that OS will not sleep before I complete my job? PS. what I want to do is different from preventing system going to sleep. I can use SetThreadExecutionState to prevent OS going to sleep, but I can not use it to prevent it going to sleep when it is already going to sleep. thanks ???? ???? wrote: > I need to do something when the OS is going to sleep. when the app &...

How to get the process id that is using a port
I have no root privilege. how could i find the process id that is using a port. Or, could I get the username who is using a port? Hi Tristan, You can use lsof command for that. "lsof -i" and you will see all processid how 're using your sockets. man page: http://www.netadmintools.com/html/lsof.man.html Regards. On 11 d=E9c, 07:21, Tristan <sooq...@gmail.com> wrote: > I have no root privilege. how could i find the process id that =A0is > using a port. > > Or, could I get the username who is using a port? Michael, Thanks. I've tried lsof but failed...

How to get a window ID in linux using python?
Hi all, Is there a way to get window ID in linux using python by just using the window name (say 'VPython')? This can be done in (Microsoft) windows (got it from somewhere else, not tested). import win32gui self.VP = win32gui.FindWindow ( None, 'VPython' ) In Linux, we can get window info by executing 'xwininfo' and then selecting the desired window manually. Can this be done automatically in python? Thanks, Sandy > In Linux, we can get window info by executing 'xwininfo' and then > selecting the desired window manually. Can this be done autom...

Using os.popen3() to get binary data
Hello everybody, I need to get the different frames from a GIF image in my python script and want to use the giftopnm program from netpbm to get the frames and directly convert them to pnm files. I tried to use the following code: for image in images: if (image[0:3] == 'GIF'): (si, so, se) = os.popen3('giftopnm -image=all', 'b') si.write(image) frame = so.readlines() But with this code the script just hangs. When I interrupt the script, I get the following error message: Traceback (most recent call last): File "/home/tiger/stock-spam/scri...

Get LINUX Process ID from Call System()
I am using Call System to execute a SAS program on LINUX. Something like: data _null_; Call System('sas programname.sas'); run; It's actually a bit more complicated a call than that, but that is the essence of it. What I am trying to figure out is, how can I get the process ID (issued by the LINUX operating system) for the program I submit using Call System? The reason why I want to know this is the following: sometimes the system has a high degree of latency, and if the program I submitted does not start in a timely manner, I want the ability to abort the job which would i...

Is There a Java Process ID For Each Process?
I have a program that logs actions to a file. I've noticed that sometimes, by accident, two instances of the program (each with a different JVM) ended up running at the same time. It took a while to sort through the entries to be sure I knew which entry was from which instance. Is there some way to get an instance number or process ID for each process -- one that I can be sure will be different for each program I run, with different instances of the JVM -- in other words, I don't want the first process or thread started by a JVM to be #1, and the 2nd to be #2. I'm looking for s...

get process id by using it's name.
Hi, folks. first ) I have a question to get a process id by using it's name for all platforms. second) If I want to kill some processes by it's name, are there efficient way to do it for all platform? For a solution for this problem, I am now using the following way ;) ex) lines = $x{ ps -Au${ENV['USER']} }.split("\r?\n") lines.each do |line| if line.match(process_name) pids << line.strip.split[0] end end count = 0 pids.each do |pid| %x{ kill #{pid} } count += 1 if $?.existstatus.zero? end print "total terminated processes : %d" % co...

How to get pid of a process when is started using open command
Hi, I have pipeline a command using open,something like below set process [open "|\"new.exe" \"inputfile.txt\" 1000" r+] which intern start a new process "new.exe" which takes some arguments. when I query for the process id uisng [pid $process] I get the process id of the file operation , But in my case I also need the new process that is open commands kick starts. How can I get the process id of the new.exe that is started by open? Regards, Raju On Wednesday, April 29, 2015 at 3:13:06 PM UTC+5:30, arokia.r...@gmail.com wrote: > Hi,...

Re: Get LINUX Process ID from Call System()
On Thu, 5 Mar 2009 11:26:52 -0500, Paul Walker <walker.627@OSU.EDU> wrote: >I am using Call System to execute a SAS program on LINUX. Something like: > >data _null_; > Call System('sas programname.sas'); >run; > >It's actually a bit more complicated a call than that, but that is the >essence of it. > >What I am trying to figure out is, how can I get the process ID (issued by >the LINUX operating system) for the program I submit using Call System? > >The reason why I want to know this is the following: sometimes the system >has a h...

Getting full process start data using PS
I am trying to obtain the exact date/time when a certain process started. However, in case the process is over a day old, I only get the date, not the time How can I get the date in full format? (preffereably using ps, but if impossible - using another command) Thanks On Mon, 13 Mar 2006 10:23:18 -0500, <michal2@gmail.com> wrote: > I am trying to obtain the exact date/time when a certain process > started. > However, in case the process is over a day old, I only get the date, > not the time > How can I get the date in full format? (preffereably using ps, but if > imp...