Hi
I have som problems with substitution in a script I am putting together and I hope someone can help me.
My problem is with the variable $EXCLUDES in the variable CMD1.
The script is showen below.
------------- script1 ---------------
#!/usr/bin/ksh
LOG=/home/user1/cleanup.log
CONF=/home/user1/cleanup.conf
EXCLUDES=`sed 's/,/\|\/sbin\/grep -v/g' $CONF`
CMD1=`grep /var/opt/ignite/clients $LOG $EXCLUDES`
for i in $CMD1;do
server=`echo $i |awk -F: '{print $1}'`
echo $server
done
------------- script1 ---------------
The contens of cleanup.log is showen below
---------- cat cleanup.log -----------
node1:/var/opt/ignite/clients
node4:/var/opt/ignite/clients
---------- cat cleanup.log -----------
The contens of cleanup.conf is showen below
--------- cat cleanup.conf -----------
, node1, node2
--------- cat cleanup.conf -----------
I get the following error showen below.
---------------- error ---------------
grep: can't open |/sbin/grep
grep: can't open -v
grep: can't open node1|/sbin/grep
grep: can't open -v
grep: can't open node2
/home/user1/cleanup.log
---------------- error ---------------
I have tryed to do an echo of $EXCLUDES and it seems to be ok, se below this line:
|/sbin/grep -v node1|/sbin/grep -v node2
But when I try to do an substitution i $CMD1 I get the error. Can someone tell me what I am doing wrong and how I can find a solution on me problem.
Regards Valle
I have som problems with substitution in a script I am putting together and I hope someone can help me.
My problem is with the variable $EXCLUDES in the variable CMD1.
The script is showen below.
------------- script1 ---------------
#!/usr/bin/ksh
LOG=/home/user1/cleanup.log
CONF=/home/user1/cleanup.conf
EXCLUDES=`sed 's/,/\|\/sbin\/grep -v/g' $CONF`
CMD1=`grep /var/opt/ignite/clients $LOG $EXCLUDES`
for i in $CMD1;do
server=`echo $i |awk -F: '{print $1}'`
echo $server
done
------------- script1 ---------------
The contens of cleanup.log is showen below
---------- cat cleanup.log -----------
node1:/var/opt/ignite/clients
node4:/var/opt/ignite/clients
---------- cat cleanup.log -----------
The contens of cleanup.conf is showen below
--------- cat cleanup.conf -----------
, node1, node2
--------- cat cleanup.conf -----------
I get the following error showen below.
---------------- error ---------------
grep: can't open |/sbin/grep
grep: can't open -v
grep: can't open node1|/sbin/grep
grep: can't open -v
grep: can't open node2
/home/user1/cleanup.log
---------------- error ---------------
I have tryed to do an echo of $EXCLUDES and it seems to be ok, se below this line:
|/sbin/grep -v node1|/sbin/grep -v node2
But when I try to do an substitution i $CMD1 I get the error. Can someone tell me what I am doing wrong and how I can find a solution on me problem.
Regards Valle