Sponsored Content
Top Forums Shell Programming and Scripting How to fetch running/failed process Post 302295033 by ce9888 on Friday 6th of March 2009 11:12:58 AM
Old 03-06-2009
Quote:
Originally Posted by vgersh99
'man ksh' yields the following:
Code:
     ?     The decimal value returned by the last  executed  com-
           mand.

In your case 'grep -v grep'
Logicaly you are right how can you explain this :

Code:
ce9888$ ps -ef | grep -i fiha                                
    user  37558      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
  ce9888  41702  50948   0 10:57:09 pts/12  0:00 grep -i fiha 
    user  56818      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  65156      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  66926      1   0 08:50:57      -  0:00 /home/s/sys/fiha 
    user  67088      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  67470      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  68270      1   0 08:50:57      -  0:00 /home/s/sys/fiha 
    user  68366      1   0 08:50:57      -  0:34 /home/s/sys/fiha  
    user  68980      1   0 08:50:57      -  0:00 /home/s/sys/fiha
    user  72298      1   0 08:50:57      -  0:05 /home/s/sys/fiha
ce9888$ echo $?
0

Code:
ce9888$ ps -ef | grep -i fiha | grep -v grep                 
    user  37558      1   0 08:50:57      -  0:00 /home/s/sys/fiha 
    user  56818      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  65156      1   0 08:50:57      -  0:00 /home/s/sys/fiha 
    user  66926      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  67088      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  67470      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  68270      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  68366      1   0 08:50:57      -  0:36 /home/s/sys/fiha 
    user  68980      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    user  72298      1   0 08:50:57      -  0:05 /home/s/sys/fiha  
ce9888$ echo $?
0

It reacts as you suggest, since grep -v did find the "grep" string.

Code:
ce9888$ ps -ef | grep -i fiha | grep -v toto
  ce9888  36474  50948   1 11:08:21 pts/12  0:00 grep -i fiha 
    spsy  37558      1   0 08:50:57      -  0:00 /home/s/sys/fiha
    spsy  56818      1   0 08:50:57      -  0:00 /home/s/sys/fiha 
    spsy  65156      1   0 08:50:57      -  0:00 /home/s/sys/fiha 
    spsy  66926      1   0 08:50:57      -  0:00 /home/s/sys/fiha 
    spsy  67088      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    spsy  67470      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    spsy  68270      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    spsy  68366      1   0 08:50:57      -  0:37 /home/s/sys/fiha  
    spsy  68980      1   0 08:50:57      -  0:00 /home/s/sys/fiha  
    spsy  72298      1   0 08:50:57      -  0:06 /home/s/sys/fiha  
ce9888$ echo $?
0

Accordingly to your assumption this one should have return 1 since grep -v didn't found the "toto" string. which its not the case...
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Unix Process Failed

Im having this problem ever since im Using Unix. Please help.Im using Linux Red Hat 7.0. 2.2.6. My Problem is. Whenever i close my unix before the system goes to Halt mode and stoping all md device, this Process shows me as fail. : Saving Mixer settings modprobe: modprobe: can't locate module... (1 Reply)
Discussion started by: killerserv
1 Replies

2. Shell Programming and Scripting

Editing file during running ksh in HP failed

Hi falks, I have the following program: #!/bin/ksh ed -s /home/ias/v9.0.3/j2ee/OC4J_RiGHTv_HPCD2/applications/Xbip/Xbip/WEB -INF/config/application.properties <<EOF >/dev/null 1 d . d . a application.filePath.core = /core-HPCD2/Html/ application.filePath.xbip =... (2 Replies)
Discussion started by: nir_s
2 Replies

3. Filesystems, Disks and Memory

skgpspawn failed running oracle db 9.2.0.5.0 on aix 5.3

Hi, I am running an oracle db 9.2.0.5.0 on ibm p5 550 aix 5.3 with 10g ram, 10G swap space 3 database instances each SGA about 500Meg. I am getting the following error in my alert log file from time to time: skgpspawn failed:category = 27142, depinfo = 11, op = fork, loc = skgpspawn3 ... (0 Replies)
Discussion started by: hawkerpacific
0 Replies

4. 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

5. Programming

Fetch running applications list in Linux

Hi, I need to write a code which will fetch all the application activity on user computers including app name, time of day, duration, version, etc. Using this I need to know which applications are running currently in user's computers. How can it be done programmatically? I need to write the... (1 Reply)
Discussion started by: arunarora
1 Replies

6. HP-UX

How to fetch all running services on HP-UX?

Hi All, I have a requirement to get all the running services on few HP-UX boxes. In Linux systems I am able to do that successfully using: chkconfig --list. However I can't find anything equivalent in HP-UX. If anyone has any pointers on the same then please suggest. Adyan (4 Replies)
Discussion started by: Adyan Faruqi
4 Replies

7. BSD

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (0 Replies)
Discussion started by: naveeng
0 Replies

8. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (1 Reply)
Discussion started by: naveeng
1 Replies

9. UNIX for Advanced & Expert Users

Process remians in Running state causing other similar process to sleep and results to system hang

Hi Experts, I am facing one problem here which is one process always stuck in running state which causes the other similar process to sleep state . This causes my system in hanged state. On doing cat /proc/<pid>wchan showing the "__init_begin" in the output. Can you please help me here... (6 Replies)
Discussion started by: naveeng
6 Replies

10. 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
All times are GMT -4. The time now is 05:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy