in reply to Re: User interaction mid script again
in thread User interaction mid script again
Now I am trying to translate this into perl (as tcl has some pecularities I don't really like. Heres what I came up with:#!/usr/dist/exe/expect -f set timeout -1 set hostname blah set login_name blah_blah spawn $env(SHELL) match_max 100000 send -- "telnet $hostname\r" expect "login:" send -- "$login_name\r" expect "Password:" interact -nobuffer -re "(.*)\r" return #ask user for password and then return to script send -- "cd $dir\r" interact
The problem is that the line:#!/usr/bin/perl use strict; use Expect; my $session = new Expect; my $server_connect = "blah"; my $username = "blah_blah"; my $shell_prompt= '(.*%|.*#|.*>|.*\\$) $'; my $dir="blah_blah_blah"; $session->spawn("bash"); print $session "telnet $server_connect\r"; $session->expect(60, -re, "ogin:"); print $session "$username\r"; $session->expect(10, -re, "assword:"); $session->interact(\*STDIN, "\r"); $session->expect(60, -re, "$shell_prompt"); print $session "cd $dir\r"; $session->interact();
does not act in the same way as the line$session->interact(\*STDIN, "\r");
does in tclinteract -nobuffer -re "(.*)\r" return
|
|---|