- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: PID with pipe command
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2004 04:16 AM
тАО11-04-2004 04:16 AM
PID with pipe command
We are running a command and piping the output to 'tee'
cmd | tee -a sample.log &
print "$!" > pid_file
Since we are using the pipe, the PPID is getting stored in the pid_file.
Could anyone tell us how to get the PID in the pid_file.
The PID stored in the pid_file will be later used for killing the 'cmd' using a
'stop script'.
Could anyone tell how we can get this functionality?
Thanks,
Siva
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2004 04:30 AM
тАО11-04-2004 04:30 AM
Re: PID with pipe command
mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2004 04:42 AM
тАО11-04-2004 04:42 AM
Re: PID with pipe command
$ perl -e 'sleep 1000; print "done\n"' | tee -a x.x &
[1] 15219
$ print $!
15219
$ ps -f
UID PID PPID C STIME TTY TIME COMMAND
root 15219 4146 0 07:29:04 pts/0 0:00 tee -a x.x
root 15220 15219 0 07:29:04 pts/0 0:00 perl -e sleep 1000; print "done\n"
root 15221 4146 1 07:29:17 pts/0 0:00 ps -f
root 4146 4138 0 Nov 2 pts/0 0:00 -sh
$ ps -f | awk -v pid=$! '{ if ($3==pid){print $2}}'
15220
hth,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2004 04:44 AM
тАО11-04-2004 04:44 AM
Re: PID with pipe command
perl -e 'if (!($pid=fork())) { exec("sleep 30") } print "$pid\n";' | read childPID
this will return pid of subprocess in childPID env var. Note that this is really basic code, and you may need to enhance fork management, redirect STDIN and STDOUT for complete separation...
Regards,
Fred
"Reality is just a point of view." (P. K. D.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-04-2004 04:47 AM
тАО11-04-2004 04:47 AM
Re: PID with pipe command
#perl -e 'if (!($pid=fork())) { exec("sleep 30") } print "$pid\n";' | read childPID
#echo $childPID
27507
#ps
PID TTY TIME COMMAND
27094 pts/tb 0:00 sh
27507 pts/tb 0:00 sleep
27093 pts/tb 0:00 telnetd
27508 pts/tb 0:00 ps
Regards,
Fred
"Reality is just a point of view." (P. K. D.)