siva_kumar25 has asked for the wisdom of the Perl Monks concerning the following question:
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.
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.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";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Replacing backticks with system() and redirecting STDERR to file
by bart (Canon) on Jan 09, 2007 at 12:11 UTC | |
|
Re: Replacing backticks with system() and redirecting STDERR to file
by jettero (Monsignor) on Jan 09, 2007 at 12:06 UTC | |
|
Re: Replacing backticks with system() and redirecting STDERR to file
by gaal (Parson) on Jan 09, 2007 at 12:03 UTC | |
|
Re: Replacing backticks with system() and redirecting STDERR to file
by ikegami (Patriarch) on Jan 09, 2007 at 15:39 UTC | |
|
Re: Replacing backticks with system() and redirecting STDERR to file
by jwkrahn (Abbot) on Jan 09, 2007 at 20:13 UTC |