Perl et Telnet

T

ThERiZla

Hi,

I do a connection on the server witn Telnet.
My problem is when I execute a command on command prompt.
This is my command : my @outputcreateUser = $telnet->cmd($createUser);
I want obtain the result of the command but when I print the array
@outputCreateUser there is nothing in the array.

This is my code to connect to the server:
## Create a Net::Telnet object
use Net::Telnet ();
$telnet = new Net::Telnet (Timeout => 20,
Input_log => $fileInput,
Output_log => $fileOutput,
Errmode => 'return',
Prompt => $prompt);
if (! defined $telnet) {
die "Unable to create telnet object for $host";
}

$telnet->open($host);
if ($msg = $telnet->errmsg) {
die "Unable to open telnet to $host $msg";
}

$telnet->login($username, $password);
if ($msg = $telnet->errmsg) {
die "Unable to login to $host $msg PWD: $password";
}
return $telnet;


I like know if I do something wrong.
An explication and an example will be appreciate.
Thanks
 
J

J. Gleixner

ThERiZla said:
Hi,

I do a connection on the server witn Telnet.
My problem is when I execute a command on command prompt.
This is my command : my @outputcreateUser = $telnet->cmd($createUser);
I want obtain the result of the command but when I print the array
@outputCreateUser there is nothing in the array.

ahhh... so your code looks exactly like:

my @outputcreateUser = $telnet->cmd($createUser);
print @outputCreateUser;

Case is important in variable names.
 
U

Uri Guttman

JG> ahhh... so your code looks exactly like:

JG> my @outputcreateUser = $telnet->cmd($createUser); print
JG> @outputCreateUser;

JG> Case is important in variable names.

another reason why StuDlyCaps is such a bad idea. it is tricky enough
getting long names correct (and strict is a must anyway) but adding case
issues makes it just annoying. i created a copy-word func in emacs long
ago in my personal perl mode that copies a name and preceding sigil so i
can paste it elsewhere. makes life lots easier when using vars multiple
times.

uri
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top