#!/usr/bin/perl use strict; use warnings; use Net::OpenSSH; my $host = 'host'; my $username = 'user'; my $password = 'pass'; my $cmd1 = 'cd /home/tests/Scripts/TestCaseScripts'; my $cmd2 = 'ls'; my $ssh = Net::OpenSSH->new($host, user => $username, password => $password, timeout => 30, strict_mode => 0, master_opts => [ -o => "StrictHostKeyChecking=no"]); $ssh->error and die "ssh failed: " . $ssh->error; $ssh->system($cmd1) or die "remote command failed: " . $ssh->error; my ($out,$err) = $ssh->capture($cmd1); $ssh->error and die "remote command failed: " . $ssh->error; $ssh->system($cmd2) or die "remote command failed: " . $ssh->error; ($out, $err) = $ssh->capture2($cmd2); $ssh->error and die "remote command failed: " . $ssh->error;
In reply to Re: Net::OpenSSH can't change working directory
by Khen1950fx
in thread Net::OpenSSH can't change working directory
by josh803316
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |