How to combine timeout and eval commands in bash -
for executing command stored in variable eval
command used:
└──> a="echo -e 'a\nb' | wc -l" └──> eval $a 2
but how can combined timeout
command? i've tried following gives me wrong output:
└──> timeout 10 $a 'a b' | wc -l
and following gives me errors:
└──> timeout 10 "$a" timeout: failed run command `echo -e \'a\\nb\' | wc -l': no such file or directory └──> timeout 10 $(eval $a) timeout: failed run command `2': no such file or directory └──> timeout 10 $(eval "$a") timeout: failed run command `2': no such file or directory
the question can stand: how can sure following command executed properly?
timeout 10 "$program" "$opt1" "$opt2" ...
this work
if timeout "$program" "$opt1" "$opt2" ... ; echo program ran else echo program terminated due timeout fi
Comments
Post a Comment