Sponsored Content
Top Forums Shell Programming and Scripting Looping not completing in shell script Post 302769065 by surender reddy on Monday 11th of February 2013 06:23:56 AM
Old 02-11-2013
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
inputfile

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
output is coming as below
HTML Code:
CPU UTILIZATION
61
sample output of command sar 2 2 is given below

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
please help to get the output for all servers and ip address of servers in output
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Looping a perl script in a shell script

I am trying to get the follow script to run in the background on the 'fly'. I can launch it via cron and it will run in the background. BUT when I launch it from the command line it will run in the foreground. I figure it has to do with the while loop I have, but I have no clue how I can run the... (8 Replies)
Discussion started by: edkung
8 Replies

2. Shell Programming and Scripting

Terminate session on completing script

Hai all.. How do i terminate my telnet session automatically when my java applicatiion exits. i have a file run which executes my java application and takes care of all class and library path settings prior to the execution. I would like to terminate my session when my application exits. The... (4 Replies)
Discussion started by: deepsteptom
4 Replies

3. Shell Programming and Scripting

looping through a variable in a shell script

hi, my first question is :- i would like to know how do i loop through the output of a variable. for ex:- if i have a variable called x and echo $x gives the output like feb 19 07 feb 20 07 feb 21 07 i would like to know how do i loop through this since it is separated and i... (1 Reply)
Discussion started by: ramachandranrr
1 Replies

4. Shell Programming and Scripting

Convert shell script for looping

Situation: I have a working shell script on our file server (OSXS Tiger) to connect to a workstation, which is using a portable home directory (phd), and rsync a user's MirrorAgent.log. I'm not that strong of a scripter (obviously), but I would like to add other workstations to this script as they... (4 Replies)
Discussion started by: le0pard13
4 Replies

5. Shell Programming and Scripting

shell script exiting before completing

I have a script which has the following statement, /opt/oracle/product/9i/bin/sqlplus << EOC >> $LOG_FILE 2>&1 username/password ---- Enters the SQL prompt @/export/home/oracle/shells/grant_userview.sql ---Runs the SQL script @/export/home/oracle/shells/grant_proc_userview.sql ---Runs the... (6 Replies)
Discussion started by: welldone
6 Replies

6. Shell Programming and Scripting

Looping through a shell script with sql statements

Hello members, I'm working on the Solaris environment and the DB i'm using is Oracle 10g. Skeleton of what I'm attempting; Write a ksh script to perform the following. I have no idea how to include my sql query within a shell script and loop through the statements. Have therefore given a... (4 Replies)
Discussion started by: novice82
4 Replies

7. Shell Programming and Scripting

C Shell Script: While function not fully looping

I am new to scripting and this is probably the 4th or 5th simple script I have written. I am working with a HUGE number of data that need to be organized into folders and named a certain way. I wrote the naming script using a while function to go through the 1000-some folders and rename the files... (0 Replies)
Discussion started by: notluckyhannah
0 Replies

8. Shell Programming and Scripting

Looping in the shell script with help of script timer.

Hello Experts- We are facing some issues in the while loop script when we use the script time to decide whether to exist from the loop or continue. Below is the script SrcExitLoop="FALSE" Src_InitialStartTime=`date +%s` Src_StartTime=`date +%s` Src_NUM_ALERTS=0 TOTAL_ALERTS=`expr <SOME... (4 Replies)
Discussion started by: Amey Joshi
4 Replies

9. Shell Programming and Scripting

Need help with completing a bash script

Hello All, I am automating a task using bash script and got stuck at this. From the below input, Meta Device Members (20) : { ---------------------------------------------------------------------- BCV DATA RDF DATA ... (7 Replies)
Discussion started by: Sam R
7 Replies

10. Shell Programming and Scripting

Simple looping in shell

Hii all. I have a problem with my shell script. This is my code while do space.exe inputs/gr$count >> outputs/t$count count=$ done I ussually work in cygwin. When i tried in linux(ubuntu, kali linux) i found error said Syntax error : end of file unexpected (expecting "do")... (6 Replies)
Discussion started by: weslyarfan
6 Replies
HTML::Filter(3) 					User Contributed Perl Documentation					   HTML::Filter(3)

NAME
HTML::Filter - Filter HTML text through the parser NOTE
This module is deprecated. "HTML::Parser" now provides the functionally of "HTML::Filter" much more efficiently with the the "default" han- dler. SYNOPSIS
require HTML::Filter; $p = HTML::Filter->new->parse_file("index.html"); DESCRIPTION
"HTML::Filter" is an HTML parser that by default prints the original text of each HTML element (a slow version of cat(1) basically). The callback methods may be overridden to modify the filtering for some HTML elements and you can override output() method which is called to print the HTML text. "HTML::Filter" is a subclass of "HTML::Parser". This means that the document should be given to the parser by calling the $p->parse() or $p->parse_file() methods. EXAMPLES
The first example is a filter that will remove all comments from an HTML file. This is achieved by simply overriding the comment method to do nothing. package CommentStripper; require HTML::Filter; @ISA=qw(HTML::Filter); sub comment { } # ignore comments The second example shows a filter that will remove any <TABLE>s found in the HTML file. We specialize the start() and end() methods to count table tags and then make output not happen when inside a table. package TableStripper; require HTML::Filter; @ISA=qw(HTML::Filter); sub start { my $self = shift; $self->{table_seen}++ if $_[0] eq "table"; $self->SUPER::start(@_); } sub end { my $self = shift; $self->SUPER::end(@_); $self->{table_seen}-- if $_[0] eq "table"; } sub output { my $self = shift; unless ($self->{table_seen}) { $self->SUPER::output(@_); } } If you want to collect the parsed text internally you might want to do something like this: package FilterIntoString; require HTML::Filter; @ISA=qw(HTML::Filter); sub output { push(@{$_[0]->{fhtml}}, $_[1]) } sub filtered_html { join("", @{$_[0]->{fhtml}}) } SEE ALSO
HTML::Parser COPYRIGHT
Copyright 1997-1999 Gisle Aas. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.8.0 1999-12-09 HTML::Filter(3)
All times are GMT -4. The time now is 07:58 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy