in reply to Capture output from backtick commands using sudo

Please read the Monastery's documentation -- particularly that on the page at which you entered the above.

Use para tags (<p>...</p>) for paragraphs, and <c>...</c> to surround code and data.

But, don't use <pre> tags. See Markup in the Monastery, Perl Monks Approved HTML tags and Writeup Formatting Tips.

  • Comment on Re: Capture output from backtick commands using sudo

Replies are listed 'Best First'.
Re^2: Capture output from backtick commands using sudo
by Anonymous Monk on Oct 03, 2013 at 15:55 UTC
    Hi, I stumbled across the same issue as you. In fact, since sudo will return: 'Upon successful execution of a program, the exit status from sudo will simply be the exit status of the program that was executed.' - you will not the the result of the 'ls'. In a specific case, what I wished for was the output of the executed program ('ls', for you). Did you find an answer for this? I'd really prefer not to use any temp files. Thanks! Norbert

      Huh? Give perl -E 'say `sudo "/bin/ls"`' a try. The exit status is not the STDOUT of the programme, but it's "return code". Like: did the command succeed?

      Cheers, Sören

      Créateur des bugs mobiles - let loose once, run everywhere.
      (hooked on the Perl Programming language)