|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | 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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Looping not completing in shell script
Hi,
Iam using below code to login to servers to get cpu utilisation. but output is coming for only one server. code is below HTML Code:
root@blr-svr-oclan-01 # more SSSC_CPU_UTIL1.sh #!/bin/sh echo "CPU UTILIZATION" while read line; do IDLE=`/usr/local/bin/sshpass -p 'xxx' ssh xxx@$line 'sar 2 2' | grep Average | cut -c38-40` USAGE=`expr 100 - $IDLE` echo $USAGE done< sssc_ips.txt HTML Code:
root@blr-svr-oclan-01 # more sssc_ips.txt 172.30.3.42 172.30.3.64 172.30.19.42 172.30.19.38 HTML Code:
root@blr-svr-oclan-01 # sh SSSC_CPU_UTIL1.sh sssc_ips.txt HTML Code:
CPU UTILIZATION 61 root@blr-svr-netap-01 # sar 2 2 HTML Code:
SunOS blr-svr-netap-01 5.10 Generic_137111-08 sun4u 02/11/2013 16:52:16 %usr %sys %wio %idle 16:52:18 52 5 0 43 16:52:20 53 5 0 42 Average 53 5 0 42 |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
Try this (be wary, this is not so secure): Code:
sshpass -p 'passwd' ssh -o StrictHostKeyChecking=no user@hostname.com <commands> |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| C Shell Script: While function not fully looping | notluckyhannah | Shell Programming and Scripting | 0 | 07-20-2011 01:26 AM |
| Looping through a shell script with sql statements | novice82 | Shell Programming and Scripting | 4 | 10-08-2009 10:12 PM |
| shell script exiting before completing | welldone | Shell Programming and Scripting | 6 | 07-02-2009 02:56 PM |
| Convert shell script for looping | le0pard13 | Shell Programming and Scripting | 4 | 06-07-2007 07:42 PM |
| looping through a variable in a shell script | ramachandranrr | Shell Programming and Scripting | 1 | 03-04-2007 07:02 PM |
|
|