![]() |
|
|
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 |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|