Results 1 to 2 of 2
Hi all,
In a shell script I tried to create a command saved in avariable called CMD.
The value of CMD is fine and I can echo it and I ...
- 07-26-2007 #1Just Joined!
- Join Date
- Jul 2007
- Location
- Odenwald
- Posts
- 1
How to execute content of var in Shell Script
Hi all,
In a shell script I tried to create a command saved in avariable called CMD.
The value of CMD is fine and I can echo it and I can execute it manually in the shell (e.g. bash)
The script is:
--------------------------------------------
CMD="$PS -ef | grep \"archpro -i $INSTANCEFILE\" | grep -v grep"
echo ${CMD}
$CMD
--------------------------------------------
The output is the following:
/usr/bin/ps -ef | grep "archpro -i /opt/cssap/instanz/P12/P12.ini" | grep -v grep
usage: ps [ -aAdeflcjLPy ] [ -o format ] [ -t termlist ]
[ -u userlist ] [ -U userlist ] [ -G grouplist ]
[ -p proclist ] [ -g pgrplist ] [ -s sidlist ]
'format' is one or more of:
So if I execute the whole command manually, it lists me exactly one process.
In the script it seems that ps is called but gets no arguments or too many arguments?
Can you help me in getting the right syntax for my command?
Kindest regards .joerg
- 07-26-2007 #2Linux Enthusiast
- Join Date
- Aug 2006
- Posts
- 631
Hi,
Use eval to evaluate the commands:
RegardsCode:CMD="$PS -ef | grep \"archpro -i $INSTANCEFILE\" | grep -v grep" echo $CMD eval $CMD


Reply With Quote