Runs a command under sudo on an already-open session and collects its output.
Internally runs sudo -S -p '' <command>, writes password followed by a newline to the
command's stdin (where -S makes sudo read it), sends EOF, then collects stdout/stderr
and the exit code.
Caveats:
the remote sudoers policy must allow password sudo and not require a tty (requiretty
off - the default on most modern distros)
command is interpreted by the remote login shell, so quote/escape it as you would on
a shell command line
Runs a command under
sudoon an already-open session and collects its output.Internally runs
sudo -S -p '' <command>, writespasswordfollowed by a newline to the command's stdin (where-Smakes sudo read it), sends EOF, then collects stdout/stderr and the exit code.Caveats:
requirettyoff - the default on most modern distros)commandis interpreted by the remote login shell, so quote/escape it as you would on a shell command line