- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: pid in shell script again...
Operating System - Linux
1753479
Members
5161
Online
108794
Solutions
Forums
Categories
Company
Local Language
юдл
back
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
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
тАО06-19-2007 12:24 AM
тАО06-19-2007 12:24 AM
pid in shell script again...
hi if thr r two process id s from the following command how to pick the second process id.
l=`ps ux | awk '/mojo/ && !/awk/ {print $2}'`
echo $l;
And if the o/p is
17665
17867
how to store this in an array and retrieve each one of thm whn needed
l=`ps ux | awk '/mojo/ && !/awk/ {print $2}'`
echo $l;
And if the o/p is
17665
17867
how to store this in an array and retrieve each one of thm whn needed
- Tags:
- PS
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2007 01:50 AM
тАО06-19-2007 01:50 AM
Re: pid in shell script again...
Hi
l=$(ps -C mojo -o pid= | sed -n "2p" )
rgds
HGH
l=$(ps -C mojo -o pid= | sed -n "2p" )
rgds
HGH
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2007 04:10 AM
тАО06-19-2007 04:10 AM
Re: pid in shell script again...
Hi
You can write a perl script as below.
#!/usr/local/bin/perl
@test = `ps ux | awk '/mojo/ && !/awk/ {print $2}'`;
foreach $test (@test)
{
print "$test\n";
}
save it to a file by name pid.pl
and chmod +x pid.pl
and invoke it
./pid.pl
HTH
Padma
You can write a perl script as below.
#!/usr/local/bin/perl
@test = `ps ux | awk '/mojo/ && !/awk/ {print $2}'`;
foreach $test (@test)
{
print "$test\n";
}
save it to a file by name pid.pl
and chmod +x pid.pl
and invoke it
./pid.pl
HTH
Padma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-19-2007 05:58 AM
тАО06-19-2007 05:58 AM
Re: pid in shell script again...
#!/bin/bash -vx
# Pick 2nd (last) PID.
l=`ps ux | awk '/root/ && !/awk/ {print $2}' | tail -1`
echo $l
# Place PIDs in array ary
l=`ps ux | awk '/root/ && !/awk/ {print $2}'`
ary=($l)
Vic
# Pick 2nd (last) PID.
l=`ps ux | awk '/root/ && !/awk/ {print $2}' | tail -1`
echo $l
# Place PIDs in array ary
l=`ps ux | awk '/root/ && !/awk/ {print $2}'`
ary=($l)
Vic
There are 10 kinds of people, one that understands binary and one that doesn't.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP