<Brad: The following scripts are referenced on page 52 of the Yin article.>

Begin scripts:

<begin romsa_L.bat script>

spawn telnet [lindex $argv 0]

set uid [lindex $argv 1]

append uid "\r"

set pass [lindex $argv 2]

set nopass "null"

if {[string match $nopass $pass]} {

set pass ""

}

append pass "\r"

expect "login: "

send $uid

expect "Password:"

send $pass

expect "*$ "

<Brad: set the following text so that it is not inline with the script, but next to (to the side of) the above line>

Note: The command expect "*$ " indicates that Expect is waiting for a system prompt that matches any string (indicated by the wildcard character *) followed by $ and a space, which is typical for a Linux system. The prompt can vary on different systems, so change all instances of this string to match the actual prompt.

set cmd [lrange $argv 4 end]

append cmd " -outc "

append cmd [lindex $argv 3]

append cmd "\r"

send $cmd

expect "*$"

set cmd "ls -l "

append cmd [lindex $argv 3]

append cmd "\r"

send $cmd

set pat "*"

append pat [lindex $argv 3]

expect $pat

send "logout\r"

spawn ftp [lindex $argv 0]

expect "*: "

send $uid

expect "*:"

send $pass

expect "ftp>"

set cmd1 "get "

append cmd1 "[lindex $argv 3]\r"

send $cmd1

expect "ftp>"

send "bye\r"

<end romsa_L.bat script>

<begin romsa_W.bat script>

spawn telnet [lindex $argv 0]

set uid [lindex $argv 1]

append uid "\r"

set pass [lindex $argv 2]

set nopass "null"

if {[string match $nopass $pass]} {

set pass ""

}

append pass "\r"

expect "login: "

send $uid

expect "Password:"

send $pass

expect "*>"

<Brad: set the following text so that it is not inline with the script, but next to (to the side of) the above line>

Note: The command expect "*>" indicates that Expect is waiting for a system prompt that matches any string (indicated by the wildcard character *) followed by , which is typical for a Windows system. The prompt can vary on different systems, so change all instances of this string to match the actual prompt.

set cmd [lrange $argv 4 end]

append cmd " -outc "

append cmd [lindex $argv 3]

append cmd "\r"

send $cmd

expect "*>"

set cmd "ls -l "

append cmd [lindex $argv 3]

append cmd "\r"

send $cmd

set pat "*"

append pat [lindex $argv 3]

expect $pat

set mvfile "move "

append mvfile [lindex $argv 3]

append mvfile " c:\\InetPub\\ftproot"

append mvfile "\r"

send $mvfile

expect "*>"

send "Yes\r"

expect "*):"

send "logout\r"

spawn ftp [lindex $argv 0]

expect "*: "

send $uid

expect "*:"

send $pass

expect "ftp>"

set cmd1 "get "

append cmd1 "[lindex $argv 3]\r"

send $cmd1

expect "ftp>"

send "bye\r"

<end romsa_W.bat script>

<begin romsa_L_su.bat script>

spawn telnet [lindex $argv 0]

set uid [lindex $argv 1]

append uid "\r"

set pass [lindex $argv 2]

set nopass "null"

if {[string match $nopass $pass]} {

set pass ""

}

append pass "\r"

expect "login: "

send $uid

expect "Password:"

send $pass

expect "*$ "

send "su\r"

expect "Password:"

send $pass

expect "*#"

set cmd [lrange $argv 4 end]

append cmd " -outc "

append cmd [lindex $argv 3]

append cmd "\r"

send $cmd

expect "*#"

set cmd "ls -l "

append cmd [lindex $argv 3]

append cmd "\r"

send $cmd

set pat "*"

append pat [lindex $argv 3]

expect $pat

send "exit\r"

expect "*$"

send "logout\r"

spawn ftp [lindex $argv 0]

expect "*: "

send $uid

expect "*:"

send $pass

expect "ftp>"

set cmd1 "get "

append cmd1 "[lindex $argv 3]\r"

send $cmd1

expect "ftp>"

send "bye\r"

<end romsa_L_su.bat script>

YinPage 111/8/2018

I:\Publications\Dell\Dell 2May 2002\Final DOCs for Eddie\YinCodeOnline.doc