in reply to Net::OpenSSH failing in unexpected way

Could you reduce this to an SSCCE?

Could it perhaps be a strange shell quoting issue? Have you tried turning on Net::OpenSSH's debugging, e.g. $Net::OpenSSH::debug |= 16; for debugging remote command execution?

Also, you might be able to reduce issues with quoting by making use of the quoting that is built into the module, and breaking the command into an array, e.g. ->capture(\%opts, 'perl', '-e', qq{print (-d '/directory/')}); (untested Update: tested, and I also wanted to suggest ->capture('perl','-e',q{print -d q{/directory/}}) instead).

If it really is a shell quoting issue, then sending Perl scripts to the remote side via perl -e might not be the best option in general. You could write a short script to run on the server side and then SCP it over to run it there.

Replies are listed 'Best First'.
Re^2: Net::OpenSSH failing in unexpected way
by nysus (Parson) on Apr 04, 2017 at 17:23 UTC

    Thanks, your suggestion to take a look at how the arguments were handled got me to look closer at how I was processing them. Best I can tell is that I was getting too cute with one of my wrapper calls and was leaking file handles through it somehow and I hit the file limit. Simplifying the wrapper call solved the problem by using capture directly.

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks