in reply to Re: Double double quoting - nested macro calls
in thread Double double quoting - nested macro calls

Thanks for the reply guys... haven't got code examples to hand I'm afraid. Something I was trying to get sorted in work today and finished for the weekend.

Basically a hierarchy of macros:
1) run a command on a remote machine & validate output etc.
2) Under the covers this calls another macro that rsh's and calls a small little standalone perl program to do what we want on the remote machine.
3) This standalone perl program then adds a string to a file.

So at each level a set of double quotes in essence is removed... so I suspect I need to pad out with "extras" to allow for the hierarchy?

By the time we get to the standalone perl program its essentially getting a

print This is the test string

rather than

print "This is the test string"

  • Comment on Re^2: Double double quoting - nested macro calls

Replies are listed 'Best First'.
Re^3: Double double quoting - nested macro calls
by Anonymous Monk on Apr 23, 2011 at 01:21 UTC
    ... By the time we get to the standalone perl program its essentially getting a ...

    I think you misunderstand, see How do I post a question effectively?

    For a recent example of this principal in action see the programs posted in Relative URI, they're small, compile and run, and they reproduce the problem ; they show sample input, desired output, actual (and erroneous) output.

    Hi :)

Re^3: Double double quoting - nested macro calls
by SitrucHtims (Novice) on Apr 23, 2011 at 07:03 UTC

    I am not a Unix GURU, so some of the usage for rsh that I have below is probably jacked up, but Sounds like this is the scenario to me.

    $string = "This is my string"; my $output = `rsh -l remoteuser host.example.com "perlprog.pl $string" +`;

    With the above code, $string is going to equal This is my string not "This is my string". Therefore when rsh is called as an external application, the resulting command on the remote system is perlprog.pl This is my string instead of the desired perlprog.pl "This is my string"

    Seems like you should be able to add the double quotes to the parameter by escaping them. Similar to the following.

    $string = "This is my string"; my $output = `rsh -l remoteuser host.example.com "perlprog.pl \"$strin +g\""`;