Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

script exits prematurely 1

Status
Not open for further replies.
Mar 31, 2004
151
US
I am using a script to administer current system as well as remote system disk space. When the script checks remote system, it exits completely without checking the current server. Any ideas?
 
Any chance we could take a look at the script in order to have any ideas ?

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks. xxxx is local machine and two other machines are remote. Now, if the first name in file is a remote machine, the script performs as usual and exits without processing other two. Initially this was in a single script. I split it up to see if it worked properly!

Code:
RUN="true"

calculate_disk_space () {

MAILFILE=$1
ServerName=$2

if [ "$ServerName" = "xxxx" ]; then
	       CMD="bdf -bi"
	    else
	       CMD="ssh $ServerName bdf -bi"
	    fi
	    echo "$ServerName"
	    $CMD | awk 'FNR > 1 {sub(/%/,"",$5); print $1, $2, $4, $5}' | while read Filesystem Kbytes Available Percent_Used
      do
         if [ "$Percent_Used" -gt 60 ] 
         then
             # Display the header only once.
	           # Increment the total error count. Only once for each error type.
             if [ "$RUN" = "true" ]; then
	              (( ALLERRS += 1 ))
	              display_header $MAILFILE "File System Errors"
	           fi
	           RUN="false"
	           # Print details to the file
             echo "$Filesystem on $ServerName $Percent_Used% used Total: $Kbytes kb Available: $Available kb" >> $MAILFILE
         fi
      done
      
 
   
}

Calling it from:


Code:
cat $DIR/monds.dat | awk '{print $1}' | while read ServerName
	 do
	    echo " hello"
	    calculate_disk_space $MAILFILE $ServerName
   done
 
The following code is working. Here, I am not reading from file. I don't understand the reason.

Code:
calculate_disk_space $MAILFILE remote1
calculate_disk_space $MAILFILE remote2
calculate_disk_space $MAILFILE local
 
has it something to do with "return codes" from remote server etc .. ?
 
Have you tried this ?
lst=$(awk '{print $1}' $DIR/monds.dat)
for ServerName in $lst
do
echo " hello"
calculate_disk_space $MAILFILE $ServerName
done

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top