Hi Monks,

Currently I am facing a problem in the below perl one liner code which is present in a perl script. 1) In this i would like to replace that "`"(backticks) with system() so that i can capture the status of the command and also would like to redirect the STDERR to the ssh'd node. Other parts of the code working fine. I have error only this part of the code.

my $command = 'ssh '. $node . ' "perl -e \'while (<>) { chomp; \$_ =~ +/(.*)\\//; \`su xxx -c \"mkdir -p \$1\"\`; \`su xxx -c \"touch \$_\"\ +`;}\' 1>>$storageRootPath_log 2>>$storageRootPath_err"'; my $pid = open ( $sshNodeStdinHandle{$node} , "| $command 2>>sivakumar +" ); #SK004 print {$sshNodeStdinHandle{$node}} /x/y/z/sample.txt,"\n";
2) If $storageRootPath_log is replaced with actual path, it's working fine. But if i use path assigned to the variable $storageRootPath_log ($storageRootPath_log = '/x/y/a/log.txt'), it is not working. I spent the whole day in this issue (tried by escaping double quotes etc.), but i could not able to solve. So can you peopel please help me to resolve this issue.

Thanks & Regards,
R.Sivakumar


In reply to Replacing backticks with system() and redirecting STDERR to file by siva_kumar25

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.