Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: Want to communicate status of the last command to Windows machine

by vladdrak (Monk)
on Dec 19, 2006 at 07:20 UTC ( #590617=note: print w/ replies, xml ) Need Help??


in reply to Want to communicate status of the last command to Windows machine

The environment variable %ERRORLEVEL% typically contains the exit status of the last running process. I say typically as it's up to the executable to properly exit with an actual error code.


Comment on Re: Want to communicate status of the last command to Windows machine
Re^2: Want to communicate status of the last command to Windows machine
by turn2me5 (Initiate) on Dec 19, 2006 at 07:37 UTC
    Right vladdrak So the problem is that how to bring that exit status back to my Windows machine, through the code above I am just telnetting to a remote machine and executing a command der Now I want to bring back the status of the process back to the Windows machine and that is the issue....!
      This code works for me against a debian etch machine -- should be very similar to another flavor of Linux, though. (You also might consider the Net::SSH module..!):
      #!/usr/bin/perl use strict; use warnings; use Net::Telnet; my $host = "somehost"; my $username = "test"; my $password = "password"; my $t = new Net::Telnet; $t->dump_log('trace.log'); # detailed packet trace $t->open($host) or die "could not connect to $host: $!\n"; $t->print($username); $t->waitfor('/ssword[:] $/'); $t->print($password); $t->waitfor('/\$ *$/'); $t->print("cp a b"); $t->getline(); # read prompt my $stdout = $t->getline(); print "stdout $stdout\n"; $t->print("echo \$?"); $t->getline(); # read prompt my $exitcode = $t->getline(); print "exit $exitcode\n"; exit($exitcode);
        Ta Thanks ...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://590617]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2014-11-24 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (137 votes), past polls