multiple command in ssh giving error
Hi
I have prepared a script which will login to each server and search for a keyword.
I want output on same machine from where m running script.
When i try to run command on any machine.. It works well.
w=$(grep -irH "keyword.com" /home/*/public_html/*);if [ $? -eq 0 ];then echo -e "\n $HOSTNAME";echo $(grep -irH "keyword.com" /home/*/public_html/* | cut -d: -f1 | uniq | awk '{for (i=1;i<=NF;i++) printf "%s \n",$i}');fi
but its not working in script with ssh
its gives below error:
script.sh: line 5: syntax error near unexpected token `('
Script is:
#!/bin/ksh
echo -e "Script to check and list if keyword is being used by any server \n" > /tmp/test.txt
for f in `cat /root/sync_script/serverlist1.txt`
do
ssh $f.exam5.com 'w=$(grep -irH "keyword.com" /home/*/public_html/*);if [ $? -eq 0 ];then echo -e "\n $HOSTNAME";echo $(grep -irH "keyword.com" /home/*/public_html/* | cut -d: -f1 | uniq | awk '{for (i=1;i<=NF;i++) printf "%s \n",$i}');fi' >> /tmp/test.txt
done
Please respond ASAP.
Thanks & Regards,
Monika
Last edited by Monika32011; 04-23-2011 at 04:10 AM.
Reason: security
|