473,809 Members | 2,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get a list of active processes under Unix

12 New Member
Hi All!
I am writting a small script that will find a parent pid and from this point find a parent of a parent in order to kill this last parent :-)

I know it sounds stange (at least ... ) but this is really what i have to do. So

When the script starts it find it's parent pid, like this

Expand|Select|Wrap|Line Numbers
  1. ppid = os.getppid()
Afterwards a list of active processes is fetched from a console command ps -Af as follows:

Expand|Select|Wrap|Line Numbers
  1. buffer = commands.getoutput("ps -Af")
and latter on using regular expression syntax i get a parrent process id of a ppid i have stored at the beginnig.

My question is, is there any "python" way to get a list of active processes? I mean not using "ps - Af" command.
It's not i don't want to do it this way, i am just curious :-)

Thanks in advance for any hints!

Best regards,
Oct 19 '07 #1
0 4068

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2177
by: Guy | last post by:
Hi I've done some projects in python for my work which invole some test scripts etc. All quite basic stuff, I find python a good language to work in but have come up against a brick wall. I'm been searching google for hours about processes pids etc. My problem is as follows the main problem code can be seen below : server = uc_server(HOST_str, PORT_num) while 1:
2
4165
by: curious_one | last post by:
Hi, Is there a way to access a single instance of an object(singleton class) across different processes ? thanks curious.one
9
338
by: JennaS | last post by:
Hi. I was just wondering if you can fork a process in .NET like you would in C Thank Jenna
3
442
by: Billg_sd | last post by:
Is there a programatic way in VB.NET to determine if a specific process is running? During an app update, I need to check if the component I'm about to replace is running. In UNIX I'd use: PS | grep -i MyApp Can this be done in .Net?
2
1791
by: murray_shane56 | last post by:
We currently have a routine that "forks" out (to use the unix term)TSQL commands to run asynchronously via SQL Agent jobs. Each TSQL command gets its own Job, and the job starts immediately after creation. Sometimes we can have too many of these jobs running at the same, and the box crawls to a slow speed until the jobs finish up. Is there a way we can limit the number of active jobs running under the SQL Agent at one time? Or is...
7
2143
by: roopeman | last post by:
i can search objects in AD,someone can tell me how to get the online Computers in AD ?
0
958
markryan57
by: markryan57 | last post by:
Greetings, I have seen different ideas on how to terminate active processes (i.e., MS Access, Excel, etc) from VB6 - what is the most effecient method of finding and terminating active processes? Thanks for the help.. mark
21
3043
by: Tom Gur | last post by:
Hi, It's seems that csh and tcsh acts a bit different when handling special characters in quotes. i.e: if i'll supply my program with the following arguments: -winpath "c:\\temp\\" tcsh will take it as -winpath "c:\temp\" and csh will take it literally (with the double-slashes). Is there a way for me to know what shell is currently running my
0
3515
by: m.gelosa | last post by:
Dear all, I wrote some weeks ago about a problem with all the committing transactions blocked for many seconds in a Commit Active state. Well, finally I solved it and I just would like to share this information. As I suspected there was a lock. I suspected log writing due to the commit active state and I was right. Using truss on the db2loggw process I found that when the db2 was blocked it was waiting on a Unix semaphore. I didn't...
0
9602
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10639
Oralloy
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...
1
10383
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10120
tracyyun
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...
0
9200
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5550
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...
0
5688
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4332
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
2
3861
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.