cebundy has asked for the wisdom of the Perl Monks concerning the following question:
my resulting remote client object contains my ssh object:my $ssh = Net::OpenSSH->new( $ip, master_opts => [-o => "StrictHostKeyChecking=no"], password=>$password, user => $user);
then I mount a smb share on the remote host with the command:client obj: $VAR1 = bless( { 'hostname' => 'qaclient6.omneon.local', 'ip' => '10.4.96.106', 'os' => 'linux', 'password' => 'passwd', 'ssh' => bless( { '_batch_mode' => undef, '_ctl_path' => '/root/.libnet-opens +sh-perl/root-10.4.96.106-27838-53771', '_default_argument_encoding' => und +ef, '_default_ssh_opts' => undef, '_default_stderr_fh' => undef, '_default_stdin_fh' => undef, '_default_stdout_fh' => undef, '_default_stream_encoding' => undef +, '_error' => 0, '_error_prefix' => [], '_expand_vars' => undef, '_external_master' => undef, '_gateway_args' => undef, '_home' => '/root', '_host' => '10.4.96.106', '_host_squared' => '10.4.96.106', '_key_path' => undef, '_kill_ssh_on_timeout' => undef, '_login_handler' => undef, '_master_opts' => [ '-o', 'StrictHostKeyC +hecking=no' ], '_master_stderr_discard' => undef, '_master_stderr_fh' => undef, '_master_stdout_discard' => undef, '_master_stdout_fh' => undef, '_mpty' => bless( \*Symbol::GEN1, ' +IO::Pty' ), '_passphrase' => undef, '_passwd' => '@BAJ@A"', '_perl_pid' => 27838, '_pid' => 27840, '_port' => undef, '_proxy_command' => undef, '_rsync_cmd' => 'rsync', '_scp_cmd' => undef, '_ssh_cmd' => 'ssh', '_ssh_opts' => [ '-l', 'root' ], '_target_os' => 'unix', '_thread_generation' => 0, '_timeout' => undef, '_user' => 'root', '_vars' => {}, '_wfm_bout' => '' }, 'Net::OpenSSH' ), 'user' => 'root' }, 'MGRemoteHost' );
I can see the mount is successful via another ssh session to the remote host, where I can cd to a directory on the mount point. Then I send the command:my $cmd = 'mount -t cifs //$server->ip}/myscripts /mnt/mgscripts -o us +er=qauser,password=Tester-01'; push @cmds,$cmd; $ssh->open_ex( { stdin_pipe => 1,stdout_pipe => 1, stderr_pipe => 1 }, + @cmd ) or my $error = "open_ex failed: " . $opts->{ssh}->error;
So to simplify, I stopped doing the mount in the script and used the mount point that the script already created on the previous run. This is what mount shows:"cd /mnt/mgscripts/latest' via open_ex and I get: 'bash: line 0: cd: /mnt/mgscripts/latest: No such file or directory'
However if issue this command via open_ex:'//10.20.56.64/myscripts/ on /mnt/mgscripts type cifs (rw,mand)'
It works! So I thought, OK, since what I want to do is mount a share, cd to it then run a perl script, this command should work: 'mount;cd /mnt/mgscripts/latest;perl CreateFiles -fspath=/mnt/qa5' Yes! it worked. Then I tried it again... Nope! I got:'cd /mnt/mgscripts/latest;ls'
So I kept testing and I found that the commands work (both the "mount;cd ...;ls" and the "mount;cd ...;perl...") exactly every other run of the script. I tried putting sleeps in between the commands:$VAR1 = [ 'bash: line 0: cd: /mnt/mgscripts/latest: No such file or di +rectory', 'Can\'t open perl script "CreateFiles.pl": No such file or d +irectory' ];
but that didn't help either.'mount;sleep 10;cd /mnt/mgscripts/latest;sleep 10;ls'
Any ideas about what could be happening? Thanks, cebundy'//10.20.56.64/myscripts/ on /mnt/mgscripts type cifs (rw,mand)'
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Net::OpenSSH: Trouble accessing a mount point mounted via the perl script
by salva (Canon) on Oct 10, 2013 at 07:41 UTC |