in reply to Re: Capture output from backtick commands using sudo
in thread Capture output from backtick commands using sudo

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
  • Comment on Re^2: Capture output from backtick commands using sudo

Replies are listed 'Best First'.
Re^3: Capture output from backtick commands using sudo
by Happy-the-monk (Canon) on Oct 03, 2013 at 16:28 UTC

    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)