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

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -