Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re^3: backticks and quotation trouble in bash

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

in reply to Re^2: backticks and quotation trouble in bash
in thread backticks and quotation trouble in 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.

Replies are listed 'Best First'.
Re^4: backticks and quotation trouble in bash
by floobit (Initiate) on Dec 18, 2012 at 15:47 UTC
    Thanks, I see it now. You have answered me perfectly.

      In bash, you can't nest backticks, but you can nest the newer, more flexible "$()" construct:

      echo "$( command arg arg '$( nested_command arg arg )' )"

      $ perl -MMIME::Base64 -e 'print decode_base64 "YWNlQHRvbW15YnV0bGVyLm1lCg=="'
Re^4: backticks and quotation trouble in bash
by floobit (Initiate) on Dec 18, 2012 at 16:03 UTC
    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.
      So how will the other admins maintain the Perl part of your bash-script? It will not be more readable for someone who does not know Perl and they might indeed prefer 6 pipes, awk and sed.

      Wouldn't it be better to write a little Perl-script with well defined in-and-output and use that as a "black box" kind of building block?


      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

      My blog: Imperial Deltronics

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009410]
[Happy-the-monk]: Good morning monks!

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2018-04-25 07:05 GMT
Find Nodes?
    Voting Booth?