The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Check FTP Status april Shell Programming and Scripting 2 05-06-2009 09:04 AM
check exit status - Expect Script iamcool Shell Programming and Scripting 1 01-02-2008 09:07 AM
how to check exit status in awk script epall UNIX for Dummies Questions & Answers 1 06-24-2006 08:27 PM
check the status and send an email with status isingh786 Shell Programming and Scripting 3 12-29-2005 07:22 PM
Ftp Status Check acheepi Shell Programming and Scripting 4 09-08-2005 04:23 PM

 
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
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 10-03-2006
zeekblack zeekblack is offline
Registered User
  
 

Join Date: Sep 2002
Posts: 16
Question Script to check status of a PID

i'm just learning scripting, and have been banging my head against this

I want to check if my WAS6 java process is running and if so..echo me a messages. If not then echo me a different messages

the problem i have is I dont know how to represent a NULL return value. If i grep for a was6 java pid, the $? is always '0'...no matter if a PID came back or not. any idea on how to write/rewrite this??

PID=`/usr/ucb/ps -auxwww |grep -i [s]erver1 |grep -v grep | awk '{print $2}'`

if [ $? -eq ] ; then ( i have also tried `if [ $PID -eq ] ; then)
echo " WAS6 is down,please restart"
else
echo " WAS6 is running, no action needed"
fi
--------------------------------------------------------------------

In addition, i've tried this variation below, which seems like works ..but i always get the error when executing..

# cat test.ksh
#!/bin/ksh
#
# Check to see if URLs respond in a given time period
#
BASE_DIR="/local/apps/adminutils"
WGET="$BASE_DIR/bin/wget"
DAT_FILE="$BASE_DIR/etc/url_check.dat"
MAIL_LIST="user@net.net"

PID=`/usr/ucb/ps -auxwww |grep -i [s]erver1 |grep -v grep | awk '{print $2}'`
if [ $PID = ] ; then
echo " WAS6 is down,please restart"
else
echo " WAS6 is running, no action needed"
fi
# ./test.ksh
./test.ksh[11]: test: argument expected
WAS6 is running, no action needed
#

~
 

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:36 PM.


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