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

Re: backticks and quotation trouble in bash

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

      UPDATE:

      > 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.

      floobit:

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

      ...roboticus

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

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (18)
As of 2015-07-01 19:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (17 votes), past polls