Help extracting process name from ps command AIX using KSH


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help extracting process name from ps command AIX using KSH
# 1  
Old 08-10-2010
Help extracting process name from ps command AIX using KSH

Hi All,

Newbie script writer and I need some help!

I'm grepping ps - eno THREAD >outfile

This gives me loads of stuff including the proc names which appear at the end of the line. They're all 10 characters long so what I want to do is cut them (and only them) from the file and put it in another file. The proc names all start with JN then there's another 8 characters after that. There's also a space before each procname. I tried using awk and substr but couldn't get it to work!

Any help much appreciated

Cheers
# 2  
Old 08-10-2010
try using this command ps -ef args > /tmp/outfile.out this will only give you the arguements and there will be no need to get rid of the rest of the stuff you are referring too.
# 3  
Old 08-13-2010
Sorry but this didn't work..

The command is not even valid!

Cheers
# 4  
Old 08-13-2010
Code:
ps -ef | grep "JN[A-Za-z]\{8\}"

# 5  
Old 08-13-2010
Post the output of:
Code:
ps - eno THREAD

and the desired output.
# 6  
Old 08-13-2010
ps -emo THREAD output

/ksh -x /powercenter/controlm/produser/lib/VAT/batchrun.sh 20100812 JNVT50001023
/ksh -x /powercenter/controlm/produser/lib/VAT/batchrun.sh 20100812 JNVI40001087

etc. There's usually about 30 of them. On the aix shell the jobname starts one space after the date but this window won't allow me to do that. Either way it's the last 'word' from the ps command.

Cheers
# 7  
Old 08-13-2010
Something like this?
Code:
ps - eno THREAD | awk '{print $NF}'

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

2. Shell Programming and Scripting

Grep for process in a ksh script

Hi I'm trying to catch a particular process (XYZ) running using a ksh script. Like So.. VarPS=`ps -ef |grep XYZ |grep -v grep` However this seems to find the process of the script itself - not the process 'XYZ' Asked in Error - I found my own typo... thanks anyway Skrynesaver (1 Reply)
Discussion started by: Mudshark
1 Replies

3. UNIX for Dummies Questions & Answers

AIX - bc and ksh

from command line in AIX: bc 18+14 32 and ctrl D to exit. i want to write shell script: !#/bin/ksh startdate=18 enddate=14 cd /tmp bc $startdate + $enddate my goal is to tell me end date is 14 days from today. With 58 posts, you have been a member long enough to use good... (2 Replies)
Discussion started by: lawsongeek
2 Replies

4. Shell Programming and Scripting

Script in KSH to check if a process its up or down.

Hi all! Im working on a simple script in KSH (just started) to check if a process its up or down, but im kind of lost with the following error. Script: #!/usr/bin/ksh psup=$(ps -ef | grep sftp | egrep -v grep | wc -l) if ($psup > 0); then echo "Process SFTP running" else ... (6 Replies)
Discussion started by: ARSport
6 Replies

5. Shell Programming and Scripting

AIX .ksh script freezes when using the mail -s command

Hello I am trying to send an email when a .KSH script is run on an AIX Machine. This email will only include a subject line that is made up of variables from within the script, and is as follows: CURRENT_DATE=`date +%Y%m%d` TIME=`date` ADMIN="myname@domain.com" date block () { ... (4 Replies)
Discussion started by: jimbojames
4 Replies

6. Shell Programming and Scripting

[KSH/Bash] Starting a parent process from a child process?

Hey all, I need to launch a script from within 2 other scripts that can run independently of the two parent scripts... Im having a hard time doing this, if anyone knows how please let me know. More detail. ScriptA (bash), ScriptB (ksh), ScriptC (bash) ScriptA, launches ScriptB ScirptB,... (7 Replies)
Discussion started by: trey85stang
7 Replies

7. UNIX for Advanced & Expert Users

daemonize a process using ksh

I'm trying to create daemon processes with ksh as follows: function start { # start script as co-process and pass an argument ./1.ksh $1 |& # print pid print $! # move the file descriptors of the co-process to 4 and 5 exec 4>&p exec 5<&p # then close... (1 Reply)
Discussion started by: rein
1 Replies

8. UNIX for Dummies Questions & Answers

command completion in .sh or .ksh in AIX environment

How do you user command completion in .sh or .ksh in AIX environment? I know you can do it by hitting <esc><esc> in bash, but how do you do it in bourne or korn shell in AIX 5.3 environment? Thanks in advance. (1 Reply)
Discussion started by: pdtak
1 Replies

9. Shell Programming and Scripting

Killing child process in ksh

I have a script that (ideally) starts tcpdump, sleeps a given number of seconds, then kills it. When I do this for 10 seconds or and hour, it works fine. When I try it for 10 hours (the length I actually want) it just doesn't die, and will actually stick around for days. Relevant part of my... (1 Reply)
Discussion started by: upnix
1 Replies

10. UNIX for Dummies Questions & Answers

extracting files using date in ksh

Hi All., 1 ssssss C2052EX 15 Mar 30 19:01 1 aaaaa C2052EX 15 Apr 3 10:12 1 ccccc C2052EX 15 Apr 4 09:28 i have files arriving like above. i am using the following to extract files arriving today ( say apr4) todaydat=`date | cut -c5-10` find... (1 Reply)
Discussion started by: pavan_test
1 Replies
Login or Register to Ask a Question