![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
| passing argument into awk | prkfriryce | Shell Programming and Scripting | 4 | 02-01-2007 04:44 PM |
| Problem when passing argument to a shell script | sumesh.abraham | Shell Programming and Scripting | 9 | 12-13-2006 12:07 PM |
| Thread Argument Passing | narom | High Level Programming | 2 | 01-19-2006 01:10 PM |
| Passing Argument to Function | AkumaTay | UNIX for Dummies Questions & Answers | 2 | 10-18-2001 07:24 PM |
| Passing argument to awk script | AkumaTay | UNIX for Dummies Questions & Answers | 1 | 08-03-2001 12:12 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Problem with Argument Passing
Greetings,
I am wrapping the monitoring commands like vmstat, sar, iostat and call via arguments I want ./unix_stats.sh -v vmstat -p <SEC> -d <Duration> to give vmstat values, and similarly iostat etc.,. Also if I give ./unix_stats.sh -v vmstat -i iostat -p <SEC> -d <Duration> should give both. My script: ####################################################################### # Check arguments, print usage # name, version and release are required while getopts "p:d:l:v:i:m:n:s:" arg do case $arg in p) SEC="$OPTARG" echo SEC=$SEC ;; d) INTERVAL="$OPTARG" ;; l) LOGFILE="$OPTARG" echo LOGFILE=$LOGFILE ;; v) VMSTAT="$OPTARG" echo $VMSTAT ;; i) IOSTAT="$OPTARG" echo $IOSTAT #./iostat.sh -p $SEC -d $INTERVAL -l $LOGFILE ;; m) MPSTAT="$OPTARG" echo $MPSTAT #./mpstat.sh -p $SEC -d $INTERVAL -l $LOGFILE ;; n) NETSTAT="$OPTARG" echo $NETSTAT #./netstat.sh -l $LOGFILE ;; s) SAR="$OPTARG" echo $SAR #./sar.sh $SEC -d $INTERVAL -l $LOGFILE ;; ?|*) Usage $* exit 1 ;; esac done and iostat.sh: ####################################################################### # Check arguments, print usage # name, version and release are required while getopts "p:d:l:" arg do case $arg in p) SEC="$OPTARG" echo SEC=$SEC ;; d) INTERVAL="$OPTARG" ;; l) LOGFILE="$OPTARG" echo LOGFILE=$LOGFILE ;; ?|*) Usage $* exit 1 ;; esac done iostat $SEC $INTERVAL >> $LOGFILE No idea where the issue is but not getting the result. Tried to put everything in the one script unix_stats.sh: added at the end of unix_stats.sh: echo $VMSTAT if [[ $? -eq 0 ]]; then echo "VMSTAT OUTPUT" ${VMSTAT} $SEC $INTERVAL >>./${LOGFILE} else echo "TEST" fi echo $IOSTAT if [[ $? -eq 0 ]]; then echo "IOSTAT OUTPUT" ${IOSTAT} $SEC $INTERVAL >>./${LOGFILE} fi For what ever input I am getting all the outputs. Can sombody throw light. Thanks Rodriguez |
|
||||
|
I percieved that initially, but the requirement is in the direction that we should be able to get only vmstat or iostat or both, from the script.
Also the argument passing needs to be v for vmstat, i for iostat, n for netstat etc./ . Hopefully i'll pull out with some solution !! |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|