linux - How to store output of sudo -S su -c <user> <command> to any variable -
i trying execute following command output not coming required.
var=$(echo "<password>"|sudo -s su -l <user> -c "<command>")
please if can? expected result: var=$(echo ""|sudo -s su -l -c "pwd") echo $var /home/bhushan $: actual result: echo $var
$:
you can use backticks
var=`sudo -s su -l -c ""`
or $(command)
syntax
var=$(sudo -s su -l -c "")
(keep in mind though sudo -s su -l -c ""
doesn't output $var
empty)
Comments
Post a Comment