The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Operating Systems > AIX
.
google unix.com



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem executing a script mr_manii Shell Programming and Scripting 5 10-06-2009 04:08 AM
Executing a shell script from windows;script present in unix rajneesh_kapoor UNIX for Advanced & Expert Users 4 05-08-2009 02:54 PM
Problem executing script through at viktor4124 Shell Programming and Scripting 2 04-06-2009 01:56 PM
Problem with executing script using ssh maethlin Shell Programming and Scripting 4 08-14-2008 02:46 PM
Problem executing a script hemangjani Shell Programming and Scripting 4 02-12-2008 02:21 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-08-2009
swati swati is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 3
Having problem with executing shell script to get the pid details!

Hello Everyone,
I am new to shell scripting and also i am very new to AIX machine
I have a question.
I have shell script which contains the follwing

"ps -e |grep $1
echo $2"

i run this schell script by doing this ./startSehllscript 3444 passed with two parameters .
Accroiding my assumption i though it will print the pid details with the parameter 2.
but when i run this script it could return me back kust a single string "passed"

I wanted to get the process deatils.
If i run this "ps -e |grep $1" in the UNIX shell it runs fine and gives me back the pid details but when i do it by the shell script it deos not return me back the pid details.
How can we write the commadn ina such a way that it will return me back the pid details.

I would really appreciate if some one can answer my question.

Thanks,
Swati
  #2 (permalink)  
Old 10-08-2009
faruk faruk is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 52
Hello,

What exactly you are trying to do? your question doesnt have any goal/scenario.

Code:
ps -e |grep $1
This will grep $1 from ps -e output....

If you are trying to find the output as PID and the corresponding process then try following....

Code:
ps -e|awk '{print $1 " " $4}'
HTH
  #3 (permalink)  
Old 10-09-2009
swati swati is offline
Registered User
  
 

Join Date: Oct 2009
Posts: 3
Rephrasing my question...

Hello,
Sorry for the inconvenience...I am rephrasing my question.

My main goal is to execute a shell script which will take "pid" as a parameter and the shell script should print the details of the "pid".
For this purpose i have created a shell script with the following content..
"ps -e |grep $1
echo $2"

When i execute the script with the parameter pid with some other parameter it does not print the pid .......

Hope it is bit clear to you....
Thanks,
Swati
  #4 (permalink)  
Old 10-09-2009
faruk faruk is offline
Registered User
  
 

Join Date: Mar 2009
Posts: 52
are you looking for a script like below?

Code:
echo " Enter the PID: "
read a
ps -ef |grep $a
  #5 (permalink)  
Old 10-09-2009
cero cero is offline
Registered User
  
 

Join Date: Aug 2006
Posts: 56
A script to display details on the process given as first argument + it's children:
Code:
ps -fT $1
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0