Sponsored Content
Top Forums Shell Programming and Scripting Display current directory for a running process for script Post 302910726 by Chubler_XL on Sunday 27th of July 2014 05:45:18 PM
Old 07-27-2014
try ps -eo pid,cmd or ps -e -o pid,args
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to make a current running process ignore SIGHUP signal?

I ask this question since sometimes i run a time-consuming ftp in foreground and forget to use nohup ftp.sh & to put this work background and can still running after i log off. Assume this ftp task have run 1 hour, and still 1 hour time to end, i don't want to abort the ftp, first, i use ctrl+Z... (3 Replies)
Discussion started by: stevensxiao
3 Replies

2. Programming

to find current running process

Hi All, The scenario is like this: There is a process say "A" which create a child process say "B" if some condition is true and process "A" terminates. "B" invokes some C program say "C" using 'execl' function. The job of program "C" is to keep polling the server until the server will be up.... (2 Replies)
Discussion started by: ranjkuma692
2 Replies

3. Shell Programming and Scripting

current running process in shell

hi what is the shell programming code to know the number of processes currently running on the machine & information about those processes. Another one is the configuration and usage of the UNIX file system? requesting all for help. thanks (1 Reply)
Discussion started by: moco
1 Replies

4. UNIX for Dummies Questions & Answers

Current Process Running.

Hi all, When I issued command ps -ef|grep Vinay in a UNIX machine, I got the following Vinay 22491 1 255 Jun 18 ? 294248:53 -sh Vinay 26628 1 255 Jun 18 ? 294237:33 -sh Could you tell me what all process is running ? Please explain each of the fields. Thanks... (4 Replies)
Discussion started by: coolbhai
4 Replies

5. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

6. UNIX for Advanced & Expert Users

how to display pid and other parameters of current process through kernel module ?

how to display pid and other parameters of current process in linux platform ? i know it can be done through a linux commmand ps -F but i want it done through kernel program thanks in advance (1 Reply)
Discussion started by: vaibhavkorde
1 Replies

7. UNIX for Dummies Questions & Answers

Running different process from current process?

I have been having some trouble trying to get some code working, so I was wondering...what system calls are required to execute a different program from an already running process? (1 Reply)
Discussion started by: Midwest Product
1 Replies

8. Shell Programming and Scripting

Command to know all the Current running process and how to kill

All, 1.What is the unix comand used for all current running process (Including All current running processes Parent ->child->subchild process) 2.If child and subchild processes are running then what is the unix command to kill parent and its all child subchild processes in UNIX. Kindly... (7 Replies)
Discussion started by: skp
7 Replies

9. Shell Programming and Scripting

List Process running under current user

Hi, i need to list the processes running only under current logged in user. EX: $ whoami oraaqw $ ps -ef | grep tnslsnr oraaqw 11403300 19267592 0 09:14:47 pts/3 0:00 grep tnslsnr oraaqw 15794208 1 0 Jan 14 - 11:59... (6 Replies)
Discussion started by: aravindadla
6 Replies

10. UNIX for Beginners Questions & Answers

How to display only the first 5 running process using top in shell scripting?

topfunc() { top } topfunc Here i used the top command inside a function,and i called the function. when executing this bash file i get all the process which are using by the kernel i just want to display only the first 5 running process. is it possible? (7 Replies)
Discussion started by: Meeran Rizvi
7 Replies
IPC::Open2(3perl)					 Perl Programmers Reference Guide					 IPC::Open2(3perl)

NAME
IPC::Open2 - open a process for both reading and writing using open2() SYNOPSIS
use IPC::Open2; $pid = open2(*CHLD_OUT, *CHLD_IN, 'some cmd and args'); # or without using the shell $pid = open2(*CHLD_OUT, *CHLD_IN, 'some', 'cmd', 'and', 'args'); # or with handle autovivification my($chld_out, $chld_in); $pid = open2($chld_out, $chld_in, 'some cmd and args'); # or without using the shell $pid = open2($chld_out, $chld_in, 'some', 'cmd', 'and', 'args'); waitpid( $pid, 0 ); my $child_exit_status = $? >> 8; DESCRIPTION
The open2() function runs the given $cmd and connects $chld_out for reading and $chld_in for writing. It's what you think should work when you try $pid = open(HANDLE, "|cmd args|"); The write filehandle will have autoflush turned on. If $chld_out is a string (that is, a bareword filehandle rather than a glob or a reference) and it begins with ">&", then the child will send output directly to that file handle. If $chld_in is a string that begins with "<&", then $chld_in will be closed in the parent, and the child will read from it directly. In both cases, there will be a dup(2) instead of a pipe(2) made. If either reader or writer is the null string, this will be replaced by an autogenerated filehandle. If so, you must pass a valid lvalue in the parameter slot so it can be overwritten in the caller, or an exception will be raised. open2() returns the process ID of the child process. It doesn't return on failure: it just raises an exception matching "/^open2:/". However, "exec" failures in the child are not detected. You'll have to trap SIGPIPE yourself. open2() does not wait for and reap the child process after it exits. Except for short programs where it's acceptable to let the operating system take care of this, you need to do this yourself. This is normally as simple as calling "waitpid $pid, 0" when you're done with the process. Failing to do this can result in an accumulation of defunct or "zombie" processes. See "waitpid" in perlfunc for more information. This whole affair is quite dangerous, as you may block forever. It assumes it's going to talk to something like bc, both writing to it and reading from it. This is presumably safe because you "know" that commands like bc will read a line at a time and output a line at a time. Programs like sort that read their entire input stream first, however, are quite apt to cause deadlock. The big problem with this approach is that if you don't have control over source code being run in the child process, you can't control what it does with pipe buffering. Thus you can't just open a pipe to "cat -v" and continually read and write a line from it. The IO::Pty and Expect modules from CPAN can help with this, as they provide a real tty (well, a pseudo-tty, actually), which gets you back to line buffering in the invoked command again. WARNING
The order of arguments differs from that of open3(). SEE ALSO
See IPC::Open3 for an alternative that handles STDERR as well. This function is really just a wrapper around open3(). perl v5.14.2 2011-09-26 IPC::Open2(3perl)
All times are GMT -4. The time now is 12:43 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy