The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Help with expect script somedude Shell Programming and Scripting 4 06-04-2009 01:39 PM
Need Help with EXPECT script markus2008 UNIX for Advanced & Expert Users 5 03-12-2008 08:49 PM
Password changing in a Script (shell and expect) chellam Shell Programming and Scripting 1 08-15-2006 12:12 AM
Using expect script in a shell script Naresh Kumar Shell Programming and Scripting 3 06-10-2006 09:54 AM
Expect Script HELP zuinc Shell Programming and Scripting 2 04-30-2002 10:42 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-10-2008
tonan tonan is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 11
Exclamation Need help with Expect and Shell script

This is my shell script which calls an expect file, i am trying to find out server.log file sizes on various servers. But what should be correct way to do that, is there any way i can run a for loop inside the expect file which can take cat <filename> as input. I know for can be used in expect file using counters but i need the content of file as input in in for loop.
---------------------------------------------------------------------

echo "Please enter your id: "
read uid
stty -echo
echo "Enter your password: "
read pass
stty echo

#loop into different boxes
for i in server1 server2 server3 server4 server5
do

#Check for the log file/clear it if there
if [ -f ~/tmp2.log ]
then
cp /dev/null ~/tmp2.log
fi

#this passes the userid pass and the servername to the expect file
expect find_server_logs.exp $i $uid $pass


#the tmp.log file contains the path of server.log file on various paths
#can this be executed within the expect file, or is there any better way to write the expect in the shell script itself.

for x in `cat ~/tmp.log`
do

# ls -l will take one input at a time from the file tmp.log and show its size
ls -l $x >> ~/tmp2.log
done

echo
echo "Hostname : $i"
echo
cat ~/tmp2.log | sort +4nr

done

________________________________________________________
#!/usr/bin/expect -f

spawn ssh [lindex $argv 1]@[lindex $argv 0] find /apps/logs/sunone -name server.log > ~/tmp.log
expect "[lindex $argv 1]@[lindex $argv 0]'s password:"
send "[lindex $argv 2]\r"
interact

*******************************

now the thing is i want the ls -l $x command to run on the various servers but fot that i have to take the inut for $x from the tmp.log file (cat tmp.log) is that possible or if there is any better way.
  #2 (permalink)  
Old 04-10-2008
tonan tonan is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 11
Looks that my question was a bit complecated. Well if anyone could give an example or resource as to how we can use a while loop in an expect file, like to read till the end of any file.

regards
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:58 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0