From: John B. (Lists) <li...@jo...> - 2007-04-05 18:50:42
|
The qr/^($promptRE)/ in the code below only matches a prompt at the start of a line (which is what my application needs). You need to remove the ^ from below to match partial words like assword or login ^ogin = "ogin" at start of line. ogin = ogin anywhere in the string (no ^ anchor). Ronald's code definitely works here :-) J. > $spawn=Expect->spawn("ssh $username\@$host /downloads/test.ksh\n"); > my %Hash=(); > #$Hash{'yes'}='yes'; > $Hash{'ogin'}='siva'; > $Hash{'ssword'}='corvino'; > $Hash{'Name'}='siva'; # The values for the remote command - > /downloads/test.ksh > $Hash{'Age'}='22'; # The values for the remote command - > /downloads/test.ksh > my $promptRE = join("|", keys %Hash); > print "-- $promptRE ---"; > $spawn->expect(10, > [ > qr/^($promptRE)/, > sub { > $spawn = shift; > my $prompt = ($spawn->matchlist())[0]; > $spawn->send($args{$prompt}, "\n"); > exp_continue; > } > ], > ); |