bash - Execute linux command from a variable -


here trying execute linux command variable in file.sh.

test.sh

out= "date";
echo $out;

output:
working perfectly.

but when try execute command pgrep vpnc

out= "pgrep vpnc";
echo $out;

output
test.sh: 1: test.sh: pgrep vpnc: not found

my expectation when above file executed,it returns pid.

i did tried eval.

out= "pgrep vpnc";
$ eval $out;

output:
test.sh: 1: test.sh: pgrep vpnc: not found
test.sh: 2: test.sh: $: not found

can 1 me how run command , store value in variable.

any highly appreciated.

it shoud ` instead of "

out=`pgrep process`; echo $out; 

display pid of process.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -