![]() |
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 |
| Expect script with file input problems | meberline | Shell Programming and Scripting | 1 | 05-29-2008 05:40 PM |
| File as input for a script | innocentspirit | Shell Programming and Scripting | 5 | 10-26-2007 01:03 AM |
| suppress echo while reading input in expect | sudhir_onweb | Shell Programming and Scripting | 1 | 07-23-2007 10:54 AM |
| Script for reading an input file | gzs553 | Shell Programming and Scripting | 1 | 10-17-2006 07:55 AM |
| file as input for script | finster | Shell Programming and Scripting | 1 | 11-11-2004 06:27 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
input from a file into an expect script ?
Hi,
I have an expect script that logs into a host (via ssh) requests the hostid then exits... I am happy with that. However how can I run the same script in a kind of 'while read line' and enter lots of hosts? My knowledge is still very limited (as you will soon see) so any other ideas would be appreciated. I am trying to update a server list with hostids for each host. I have never logged onto each host before and thus have not set up ssh_keygens. I have attempted to run the following, but it does not like the host input... > cat ./hostid_gathering #!/bin/bash cat ./host_list | while read LINE; do ./expect_script done ---------------------------------------------------------------------- > cat expect_script #!/opt/sfw/bin/expect -f set timeout -1 set USER "me" set PASSWORD "my_password" set HOST "$LINE" <------ Input from the while script does not work spawn ssh -l $USER $HOST expect "assword:" send "$PASSWORD\r" expect "*%" send "hostid; exit\r" expect; # waits for eof, so output is flushed? puts "\n\nexpect script exiting normally\n"; ---------------------------------------------------------------------- > ./hostid_gathering can't read "LINE": no such variable while executing "set HOST "$LINE" " (file "/expect_script" line 7) can't read "LINE": no such variable while executing "set HOST "$LINE" " (file "/expect_script" line 7) ---------------------------------------------------------------------- Any help would be greatly appreciated... My next worry will be when the ssh asks for a yes or no answer first, before requesting a Password response. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|