> Running Active Tcl 8.4.14 on Windows XP.
> Are there any known issues with Expect when called from a 2 level
> nested procedure? I have an FTP Expect script that hangs when the
> calling script is moved to a procedure.
> E.G This works - top level script calls dialog procedure(see below
> for dialog proc details.
> expectFTP,tcl
> .................
> .................
> set variables
> spawn ftp $host
> set prompt "(Name|login|Login|Username|User).*:.*"
> set sendString "$user1"
> # call diaglog proc
> dialog $spawn_id $prompt $sendString
> #set prompt "Password:"
> set sendString "$userpassword1"
> #call dialog proc
> dialog $spawn_id $prompt $sendString
> E.G This fails - top level script calls expectFTP_proc procedure
> which calls dialog proc details. The "spawn" creates the FTP
> connection, identifies the "User" prompt and submits the "userid" send
> string but then the script hangs on "Password". The debug output
> indicates that there is no response from the "userid" send so the FTP
> server waits for the userid while Expects looks for the password
> prompt.
> This only occurs when the code that calls dialog.proc is moved from
> the top level script into a procedure.
> I can email the complete script is anyone is interested .
> Thanks.
> Patrick.
> expectFTP,tcl
> .................
> .................
> set variables
> # call expectFTP_proc
> expectFTP_proc
> set variables
> spawn ftp $host
> set prompt "(Name|login|Login|Username|User).*:.*"
> set sendString "$user1"
> # call diaglog proc
> dialog $spawn_id $prompt $sendString
> #set prompt "Password:"
> set sendString "$userpassword1"
> #call dialog proc
> dialog $spawn_id $prompt $sendString
> ==================================================
> proc dialog { ftpSpawnId prompt sendString } {
> global ftpErrorMatch
> puts \n
> puts "spawnid is $ftpSpawnId"
> puts "expected prompt is $prompt"
> puts "sendString is $sendString"
> exp_log_user 1
> expect {
> -i $ftpSpawnId
> -re $prompt {
> puts "matched on prompt"
> exp_send "$sendString\r"
> exp_send_user "$sendString\n"
> }
> "Unknown host" {
> puts "ERROR: Unknown host"
> expect *
> error "Expected: '$prompt'. Saw: $expect_out(buffer)"
> }
> $ftpErrorMatch {
> puts "ERROR: FTP Error"
> expect *
> error "Expected: '$prompt'. Saw:
> $expect_out(buffer)"
> }
> timeout {
> puts "ERROR: timeout exceeded"
> expect *
> error "Expected: '$prompt'. Saw: $expect_out(buffer)"
> }
> eof {
> expect *
> error "Expected: '$prompt'. Saw: $expect_out(buffer)"
> }
> }
> return [ array get expect_out ]
> }
One problem you should look into is your calls to expect inside your