in reply to Re: Command Executing problem in perl.
in thread Command Executing problem in perl.

Hi mantager,
Thanks for ur input.
This below command should have to run in the remote machine and output should be redirect to the file.

mminfo -q "savetime>3/1/12,name=DISASTER_RECOVERY:\\" -av -ot -r clien +t >/home/rbr/clnts

I am executing this command from my local machine using perl script through SSH as I said earlier.
I have tried to create the output file in the remote machine. But now I am cleared that, we can't create the output file in the remote machine
by redirecting the output from one of our monks reply.

Note:
- After colon there should be two slash.
- We can use single quotes also instead of double quotes.

Replies are listed 'Best First'.
Re^3: Command Executing problem in perl.
by mantager (Sexton) on Jun 28, 2012 at 07:15 UTC

    Hi leslie.
    Creating the file on the remote machine is not impossible, it's only a matter of quoting the string the right way.
    In your case, it's also a matter of isolating that > sign you have inside your parameters, because otherwise it's interpreted by the remote shell as a redirection.

    With this:

    my @cmd = ( 'ssh', '-x', $remotehost, q['mminfo -q "savetime>3/1/12,name=DISASTER_RECOVERY:\\\\" -av -ot + -r client > /home/rbr/clnts'] ); print qx/@cmd/;
    you should get the result you expect. I assumed the \ after the colon is just one, because if you launch directly the command:
    mminfo -q "savetime>3/1/12,name=DISASTER_RECOVERY:\\" \ -av -ot -r client >/home/rbr/clnts
    from the shell, one of the \ is eaten by the shell. The four \\\\ should be equivalent. I tried this with a "mminfo" command that is just a script echoing its arguments, and this is what I get:
    -q savetime>3/1/12,name=DISASTER_RECOVERY:\ -av -ot -r client
    and it's written in a file on the remote machine.

    Cheers.