From: <db...@CT...> - 2003-06-18 18:42:33
|
Just a hunch: try setting $Expect::Log_Stdout=0; and see if the problem still remains. Kit Stube <uni...@iw...> Sent by: To: exp...@li... exp...@li...urc cc: eforge.net Subject: Re: [Expectperl-discuss] problems with logging 06/18/2003 10:13 AM sorry for the unclear problem report, the problem i am having is the output from the /usr/bin/last is showing up in the log (which i have maped to a function so i can fiddle with it a bit before dumping it in a file) there are also other things showing up, for example bin/sh appears, i have placed my code at the bottom of this email. and i apprecate the suggestion on net::telnet, i am currently printing the documentation on so that i can review its implementation. i thank you for your time and suggestions, they are all apprecated and considered. On Tue, 17 Jun 2003, expect wrote: > On Tue, 17 Jun 2003 15:05:35 -0500 (CDT) > Kit Stube <uni...@iw...> wrote: > > > I am having difficulty controling how expectperl is dumping output to the > > log file. > > > First you should really use Net::Telnet and second you really haven't defined > your problem. Saying that you're "having difficulty" isn't telling anyone > enough. Is the file empty? Does have only part of what you expect it to have? > Is the remote machine not printing back the data? > > And third try Net::Telnet ;^) > > > > > i get the cat /etc/passwd like i desire but i also get the launching of > > bin/sh the prompt and the last which i do not desire (this is just a dummy > > program to solve the exact same problem in my larger one so ignore the why > > would you want to of the /usr/bin/last), i have tried everything i can > > think of and still no idea why it is broken, any thoughts? > > > > > > ----code----- > > > > > > #!/usr/bin/perl -w > > use strict; > > use Expect; > > > > $|++; > > > > #open STDERR, "/dev/null"; > > > > my $username="testuser"; > > my $password="password"; > > my $host="localhost"; > > > > my $timeout=4; > > > > my $exp = new Expect; > > > > #$exp->debug(3); > > > > $exp->log_file("/dev/null"); > > $exp->log_file(undef); > > > > print "Content-type: text/html\n\n<html>"; > > > > telnet_login($username,$password,$host,\$exp); > > > > $exp->expect($timeout, > > ['ncorrect', > > sub { print "<center>ERROR:<br>Login Incorrect, check username or password</center>\n"; &html_stop; die; } ], > > [timeout => > > sub { > > $exp->send("/bin/sh\n"); > > $exp->send("/usr/bin/last -5 $username\n"); > > > > $exp->clear_accum(); > > $exp->log_file(\&formatoutput); > > > > $exp->send("/bin/cat /etc/passwd\n"); > > > > $exp->log_file(undef); > > } > > ], > > ); > > > > $exp->soft_close(); > > > > print "</html>\n"; > > > > sub formatoutput { > > my $input = shift; > > > > chomp($input); > > $input =~ tr/\r//; > > $input =~ s|\n|<br>\n|g; > > > > print $input; > > } > > > > sub telnet_login > > { > > my ($username, $password, $host, $exp) = @_; > > > > $$exp->raw_pty(1); #treat this terminal as a raw file > > $$exp->log_stdout(0); #do not show terminal output to STDOUT > > > > $$exp->spawn("/usr/bin/telnet $host") || die "Cannot open telnet\n"; > > > > $$exp->expect(7, > > ['ogin:', sub { > > $$exp->send("$username\n"); exp_continue; } ], > > ['assword:', sub { $$exp->send("$password\n"); } ], > > [timeout => sub { die "<center>ERROR: <BR>A timeout has occured at login</center>\n"; } ], > > ); > > } > > ------------------------------------------------------- This SF.Net email is sponsored by: INetU Attention Web Developers & Consultants: Become An INetU Hosting Partner. Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission! INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php _______________________________________________ Expectperl-discuss mailing list Exp...@li... https://lists.sourceforge.net/lists/listinfo/expectperl-discuss |