Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Re: backticks and quotation trouble in bash

by LanX (Chancellor)
on Dec 18, 2012 at 15:10 UTC ( #1009393=note: print w/ replies, xml ) Need Help??

in reply to backticks and quotation trouble in bash

It's a bash-quoting problem, since you can't nest backticks! ...`nslookup $1`...!

But there is a Perl solution: try qx or even system within perl to avoid disambiguation.

Cheers Rolf

Comment on Re: backticks and quotation trouble in bash
Download Code
Replies are listed 'Best First'.
Re^2: backticks and quotation trouble in bash
by floobit (Initiate) on Dec 18, 2012 at 15:26 UTC

    If it was a bash problem, why does the awk example work? Also, the tools you gave me are ways of calling bash from perl. I'm having trouble calling perl from bash.

      again ...qx/nslookup $1/ ... should do.

      > why does the awk example work?

      no nested backticks?

      > are ways of calling bash from perl

      exactly, thats the ill thing about your construct, your calling perl from bash to call a system command.

      Cheers Rolf


      > No commentary on the fact that I should just write the whole program in perl, please. I would if I could.

      LOL. This is a Perl help board, if you're not interested to learn our solutions you should consider hiring someone who does the tricky things for you.

        Thanks, I see it now. You have answered me perfectly.
        Unfortunately, it's more a restriction that "all my programs be in bash" for maintainability by other admins who potentially don't know perl. Using perl like I am here is a bit of a stretch, but it seems silly to use 6 pipes with alternating awk and sed lines when this is more readable and flexible, especially because the whole line can be commented as "get the hostname using DNS". Alas.


      Because the awk example, as mentioned by LanX doesn't try to nest backticks.


      When your only tool is a hammer, all problems look like your thumb.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009393]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2015-11-26 00:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (695 votes), past polls