In the code below I am trying to clone a git repository to another machine using a Perl script.
If I print $output, I am getting all the login messages i.e, the contents of /etc/motd/, but not the actual command output.
How to resolve this issue? Am I doing something wrong in the execution of the ssh command?
sub myexec_remote
{
my($cmd, $hostname, $filename) = @_;
my $stdout = $stderr = $exit= "";
my ($output) = `ssh $hostname $cmd 2>&1`;
## this is the command i.e, executed
##command is ssh 111.22.11.32 "git clone --bare [email protected]:/nfs/git/ /nfs/new123/"
$exit = $?;
if (defined $output)
{
open(MYOUTFILE, ">$filename");
print MYOUTFILE "$output";
close(MYOUTFILE);
}
}
I am using the backticks because sometimes ssh is done without passwordless and I have seen that the NET:SSH module doesn't support it...