hi all
This is the fifth time you have posted the same mail. Please avoid this, it is annoying
i have got a code for file transger between two linux systems through ssh
here is the code
Did you run this code and see what happens?
#!usr/bin/perl
when you are developing code make sure add these lines, will save you a lot of debugging time
use strict;
use warnings;
use Net::SSH qw(sshopen2);
my $user="username"; my $host="hostname"; my $cmd="commanad";
sshopen2("[EMAIL PROTECTED]",*REAEDR,*WRITER,"$cmd") or die "ssh :$!";
while(<READER>)
{
chomp();
print "$_\n";
}
close(READER);
close(WRITER);
The code that you have posted here is straight out the Net::SSH doc. This is not your attempt
In the above code, how to write th commanf $cmd. is it by using get or put.
what is *READER and *WRITER.
AND FROM WHERE THE SYSTEM IS GOING TO GET THE PASSWORD
please help me in this regard..
I have never used Net::SSH, so I don't have any idea as to what sshopen2 does or how it works
I think it should be similar to open2 from IPC::Open2. Read through perldoc IPC::Open2 and try to correlate
To answer your question about getting the output from a command, these are some options
my $cmd_output = `command`; #perldoc perlop, for info on backticks
if ($?) { #do some error handling}
When you are using external commands make sure to check $?
You can get the exit status, signal the external program exited on etc. from this variable
perldoc -f system #On how to get the above information from $?
Another option is to use open
open (YOURCMD, "$command|") or
die "failed to execute command $command, $!\n";
#Note, open will fail only if it failed to execute the command, not if the command exits with an error status
#For how pipes in open work and what it returns in this case, read through these docs
perldoc -f open
perldoc perlopentut
while (<YOURCMD>) { #do something with the output }
close (YOURCMD) or die "$command errored, $?\n"; #If the command exits with an error status, you can capture it here in close perldoc -f close
with regards uday
You send your regards here but don't seem to care a lot about this list's etiquette. You are expected to read through the docs, try your code out and come here with specific problems.
Did you try reading through any of the perl books that are available? Did you read through any online tutorials that are available? Follow these links for some useful resources
http://learn.perl.org
http://learn.perl.org/library/
If you do decide to reply to this mail, please don't reply to me in person, reply to the list.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]