Sponsored Content
Top Forums Shell Programming and Scripting How to keep staying on remote server after executing a shell script with if then exit end statement? Post 302985250 by moonmonk on Monday 7th of November 2016 02:51:13 PM
Old 11-07-2016
the purpose of this code is checking parameter existence. if we do not pass any parameter to this script, the script will terminate and print ....Usage:
Code:
if [ $# -le 0 ]
then
        echo "Usage: $0 product_name APPLICATION_ID"
        exit 1
fi

-------------------------
also i have update the code to
Code:
echo "\$# value is : " $#
if [ $# -ne 1 ]
then
    echo "Usage: $PROG hostname"
    #exit 0
    echo " exit 1 " 
fi        

$>.  sync_af  

$# value is :  0
Usage:  hostname
 exit 1

==============
It works on old data centers. but not on new data center .
thank you

---------- Post updated at 02:51 PM ---------- Previous update was at 02:44 PM ----------

$> check_df
Code:
#!/bin/ksh
# This script checks the percentage of disk usage 
# and will send an email if disk usage is more than 80%(default).
# You can reset the threshold by assigning a value to threshold variable @ line 19 

CURDIR=`dirname $0`
. $CURDIR/commands

if [ $# -le 0 ]
then
        echo "Usage: $0 product_name APPLICATION_ID"
        exit 1
fi

SERVER=$1
PROGRAM=`basename $0`
PROG="${2}+$PROGRAM"

typeset -i threshold=80
typeset -i USAGE
tmpfile=/home/dba/oracle11g/amreview/bin/$PROGRAM.$$.tmp
touch $tmpfile

for Disk in `df -P| grep '%' | grep '^/' | awk '{print $6}'`
do
  INFO=`/bin/df -h -P $Disk| awk '{print $5,$6}'`  
  INFO=`echo $INFO | awk '{print $3,$4}'`
  USAGE=`echo $INFO | cut -d% -f1`
  if (( USAGE > threshold ))
  then
      echo "Warning :DISC usage :$INFO " >>$tmpfile
  fi
done

if [ -s $tmpfile ]
then 
    $CURDIR/writelog -p $PROG -s 4 -S $SERVER -f $tmpfile
fi

/bin/rm $tmpfile


Last edited by vbe; 11-07-2016 at 04:15 PM.. Reason: code tags - not icode, added ident
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

executing a remote location script from local server

hi i am having two servers one is local and remote(FTP)server.from local server i have to connect to remote server and execute a shell script i want to run a shell script(remote location) from my local server i am having some knowledge on ftp but i am not getting the result .please give ... (2 Replies)
Discussion started by: srivsn
2 Replies

2. Shell Programming and Scripting

executing mysql load statement from shell script

Hi, I have a piece of shell script which will connect to mysql database and execute a load statement(which will load datas in a file to the database table).The code is working and the data is in the tables. Now my requirement is, i need to grab the output from the load statement... (4 Replies)
Discussion started by: DILEEP410
4 Replies

3. Shell Programming and Scripting

Need help on how to exit a script run on a server from a remote server

hi, I am using the below line to run a script from remote server(say server A) to another server(say server B). ssh username@servername ksh script name. The issue is the script logs into server B, executes the script on server B, transfers the file to server A but does not exit from... (4 Replies)
Discussion started by: yohasini
4 Replies

4. Shell Programming and Scripting

Problem executing perl script on remote server

Hello, I am running in to a problem running a perl script on a remote server. I can run a simple script test.pl which contains just a print statment without issue by running ssh root@1.2.3.4 perl test.pl However, I have a more complex script that does not execute as expected. I think I... (3 Replies)
Discussion started by: colinireland
3 Replies

5. Shell Programming and Scripting

Executing local script/command on remote server

I have a command that I want to run on machine B from machine A. If I run the command on machine B locally, it works fine. Here is the command: for n in `find /data1/ -name 'ini*.ext'` ; do echo cp $n "`dirname $n `/` basename $n .ext`"; done From machine A, I issue this command ... (3 Replies)
Discussion started by: dirtyd0ggy
3 Replies

6. UNIX for Dummies Questions & Answers

Executing a script in remote server

Hi All, I have 2 servers A and B. I need to connect to server B from server A and execute a shell script in B which will create some files and i need to copy those files back to server A. Required easiest possible for perfoming above task. (1 Reply)
Discussion started by: Girish19
1 Replies

7. UNIX for Dummies Questions & Answers

Execute shell script and if string found while executing then exit

Hi All, I have one shell script start.sh which executes another shell script test.sh something like below :test.sh -param1 -param2 In the test.sh there is one command for removing file:rm file1.bak I want whenever I execute start.sh, it will execute test.sh and if it finds string rm... (7 Replies)
Discussion started by: ORAI
7 Replies

8. Shell Programming and Scripting

Executing 'exit' command from shell script

Hi, I am writing shell script to automate few use cases for CLI interface. We have CLI interface which has bunch of commands. I am trying to execute one of the commands 'exit' as part of automation to exit from CLI object (not from shell script) in my shell script. My intension is to execute... (4 Replies)
Discussion started by: Mahesh Desai
4 Replies

9. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 12:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy