From: Bruno N. <bn...@gm...> - 2007-06-12 04:52:57
|
Hello Roland and guys on the list, Thank you for maintaining the Expect module. I'd like to inform you of a very annoying bug in ssh.pl script that almost ruined me when i was trying to learn expect. The bug consist of mistakenly assingning two different instances of Expect class to the $spaw variable. The two assignments are marked with '<<<<<<<' : -------------ssh.pl snippet--------------------------------- my $spawn = new Expect; <<<<<<<<<<<< instance one $spawn->raw_pty(1); # This gets the size of your terminal window $spawn->slave->clone_winsize_from(\*STDIN); my $PROMPT; # This function traps WINCH signals and passes them on sub winch { my $signame = shift; my $pid = $spawn->pid; $shucks++; print "count $shucks,pid $pid, SIG$signame\n"; $spawn->slave->clone_winsize_from(\*STDIN); kill WINCH => $spawn->pid if $spawn->pid; } $SIG{WINCH} = \&winch; # best strategy $spawn=Expect->spawn("ssh $username\@$host"); <<<<<<<<<<< Instance two!!!!! # log everything if you want # $spawn->log_file("/tmp/autossh.log.$$"); -----------------end ssh.pl snippet--------------------------- After the second assignment all the configuration done previously is lost, remarkably the setting '$spawn->raw_pty(1)' that dramatically changes the behaviour of CRLF convertions. By reading your ssh.pl i thought that using raw_pty(1) was necessary for my own application - but it wasn't!! It took me 10 hours to discover this!!! >:-( I don't understand much about terminals and character convertions so this bug was incredibly difficult to understand in my tests. When you'll fix ssh.pl, all the setting done before the second assignment is not needed. the script works perfectly only with the second assingment on. Hope this helps, bruno |