hello,

i want to append a dynamic string stored in a variable to the beginning of each 
output row of the expect command, but do not know how to do it. can anyone help 
pl?

module used is  Expect

I am using this statement before i run any command on remote host, it captures 
EVERYTHING. I want to pre-append each line with a string ....



my ( $pty, $pid ) = $ssh->open2pty({stderr_to_stdout => 1}, 
'/usr/local/bin/sudo', -p => 'runasroot:', 'su', '-')


my $expect = Expect->init($pty);


$expect->log_file("$OUTPUTLOG"); 

$expect->expect(3,
                                [ qr/runasroot:/ => sub { 
shift->send("$PASS\n");exp_continue;} ],
                                [ qr/[Sorry|Permission]/ => sub { die "Login 
failed: check sudo path"; } ]
                                );
foreach my $cmd (@cmds){
                $expect->expect(3,
                                [ qr/#/ => sub { shift->send("\n$cmd 
\n");exp_continue;}]
                                );
                $expect->expect(5);
                }



i want to append an string to the beginning of each line of output from running 
the command, but i am not sure how to catch the output of each command before 
it goes into log file.....


ty
Rajeev


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to