JoeJaz has asked for the wisdom of the Perl Monks concerning the following question:
I believe that perl thinks that $SUBJECT is a variable and is trying to store it into @vacation_str, but failing to do so. I am looking for a way to escape the $ before it is stored into @vacation_str so it won't see $SUBJECT as a variable. I also had my eye on the Net::Telnet functions 'get' and 'getlines' to try take the input a different way. However, I don't know if this is a dead end. I am greatful for any advice that anyone has on this issue. Thanks for reading this. Joe#!/usr/bin/perl my $username="user1"; my $password="password"; my $host="localhost"; my $CAT = "/usr/bin/cat"; my $LAST = "/usr/bin/last"; &start_login; print "@vacation_str\n"; sub start_login { my $telnet = new Net::Telnet; telnet_login($username,$password,$host,\$telnet); @vacation_str=$telnet->cmd("$CAT /home/$username/.vacation.msg"); telnet_close(\$telnet); } sub telnet_login { use Net::Telnet; my ($username, $password, $host, $telnet) = @_; my $error_msg = "Incorrect username or password, please try again" +; my $error_type = "ERROR"; $$telnet = new Net::Telnet ('Timeout'=>'7', 'Errmode'=> sub { &report_error($error +_type,$error_msg); }, 'Prompt'=> '/.*([\$#\%>~]|\\\[\\e\[0m\ +\\] \[0m)\s?/' ); $$telnet->open(Host=>$host); $$telnet->login($username,$password); } sub telnet_close { my $telnet=shift; $$telnet->close; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Can't get $ from Net::Telnet
by phydeauxarff (Priest) on Jun 25, 2003 at 22:54 UTC | |
by JoeJaz (Monk) on Jun 27, 2003 at 14:47 UTC | |
|
Re: Can't get $ from Net::Telnet
by Zaxo (Archbishop) on Jun 26, 2003 at 12:36 UTC | |
by JoeJaz (Monk) on Jun 27, 2003 at 14:39 UTC |