Passing eval value to a variable

Hello,

I have a script that does an scp to a server and then gets the number of process running on that server, the o/P should be stored in a variable for further processing

eval `echo "ssh -q $Infa_user@$host 'csh -c $CMD '"`
where
CMD="ps -ef | grep -i ${INFA_REPO} | grep -v grep | wc -l"

the eval command works fine in the script and o/P the no of processes however when i put it a variable, i get an errror i.e

STATUS=`eval `echo "ssh -q $Infa_user@$host 'csh -c $CMD '"``

results in error : not found [No such file or directory.

Any idea's how to do that ?

i found it

status=`eval "eval "echo "ssh -q $Infa_user@$host 'csh -c $CMD '"""`

works fine.

No need for all the extra layers. On my machine, the following does the same thing:

$ cmd1="ps -efwww | grep sbin"
$ cmd2="bash -c '$cmd1'"
$ results=$(ssh -q myhost "$cmd2")

or simply

$ results=$(ssh -q myhost "$cmd1")

eval has its uses, but only at the Ph.D level :cool: