Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked

Re: backticks and quotation trouble in bash

by LanX (Bishop)
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

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 all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2018-06-18 04:48 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.