in reply to Re: Net::OpenSSH quoting problems
in thread Net::OpenSSH quoting problems

That doesn't work
#with the debug flag set $Net::OpenSSH::debug |= 16; $object =~ s/( \d+-\d+)/\\$1/g; $cmd = qq|blah blah $object blah blah|; ( $output, $errput ) = $ssh->capture2( $cmd ) or $logger->logdie( "bad".$ssh->error ); using the debugger x $object item 0-7 0-9 after substitution x $object item \\ 0-7\\ 0-9' # lot of stuff removed the #open_ex ...... 'blah blah item\\ 0-7\\ 0-9
It sending a \\ not "item\ 0-7\ 0-9"

Replies are listed 'Best First'.
Re^3: Net::OpenSSH quoting problems
by Laurent_R (Canon) on May 13, 2014 at 07:44 UTC
    This works for me:
    DB<5> $object = "2-4 5-12" DB<6> $object =~ s/([-\d]+)/\\$1/g DB<7> p $object \2-4 \5-12
    Or you could store the backslash in a variable and use that variable:
    DB<11> $c = '\\'; DB<12> p $c \ DB<13> $object = "2-4 5-12" DB<14> $object =~ s/([-\d]+)/$c$1/g; DB<15> p $object \2-4 \5-12
Re^3: Net::OpenSSH quoting problems
by soonix (Chancellor) on May 13, 2014 at 13:08 UTC
      Ok so when I use p to look the variable it look correct But, it still not right when I look at the debug from NET::OPENssh The string being sent still has the double \\ and the appliance reject this and I get an error
        Set $Net::OpenSSH::debug = -1 in order to see what is the module actually sending to the remote host.