If you use the utility 'expect', it will make your life WAY easier. That utility should come with a script called autoexpect. Once you have it, just run the 'autoexpect' command and issue the commands that you wish to use. Once that is done, type 'exit'. That will drop you out of the script creation and write the file... it defaults to script.exp. Once that is done, edit the file to accept positional variables.
Here's an example:
Code:
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}
set timeout -1
set host [lindex $argv 0]
set ip [lindex $argv 1]
spawn telnet $host
match_max 100000
expect -exact "Username: "
send -- "user\r"
expect -exact "Password: "
send -- "pass\r"
expect -exact "HR>"
send -- "en\r"
expect -exact "Password: "
send -- "pass\r"
expect -exact "HR#"
send -- "ping\r"
expect -exact "Protocol \[ip\]: "
send -- "\r"
expect -exact "Target IP address: "
send -- "$ip\r"
expect -exact "Repeat count \[5\]: "
send -- "10\r"
expect -exact "Datagram size \[100\]: "
send -- "36\r"
expect -exact "Timeout in seconds \[2\]: "
send -- "1\r"
expect -exact "Extended commands \[n\]: "
send -- "\r"
expect -exact "Sweep range of sizes \[n\]: "
send -- "\r"
expect -exact "HR#"
send -- "q\r"
expect eof
In this example we have created a script to login to a cisco router and ping hosts. If you create a file with a list of ip addresses, each on their seperate lines, then use something like this:
Code:
for ip in `cat file`
do
/path/to/script.exp $1
more code...
done
Although now that i read your post completely, it seems as though that what i have suggested wont work. Why do you want to use FTP to get the size of the directory?