LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Closed Thread
  Search this Thread
Old 04-23-2011, 04:08 AM   #1
Monika32011
LQ Newbie
 
Registered: Apr 2011
Posts: 7

Rep: Reputation: 0
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
 
Old 04-23-2011, 04:47 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Please don't cross-post, it is against the LQ rules

Continue in this thread: multiple command in ssh not working for me.

Don't demand an immediate answer, we are all volunteers here.....

Reported.

Last edited by druuna; 04-25-2011 at 08:31 AM. Reason: fixed URL
 
Old 04-25-2011, 08:20 AM   #3
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
Welcome to LQ. I hope you get as much out of it as I have.

Although I would have added a "please" to the "we are all volunteers here" part, druuna is right on both counts. So, please read or re-read those rules, & again welcome.

Last edited by archtoad6; 04-27-2011 at 04:12 AM. Reason: missing word
 
Old 04-26-2011, 07:32 AM   #4
fiku
LQ Newbie
 
Registered: Oct 2010
Posts: 25

Rep: Reputation: 2
Quote:
Originally Posted by Monika32011 View Post
#!/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=[...] awk '{for [...] $i}');fi' >> /tmp/test.txt
done

Probably, the error occurs due to bolded apostrophes (too much of them - You should have 2 instead of 4). Try to rewrite it, so that You use proper open-close apostrophes scheme.
 
  


Closed Thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
multiple command in ssh not working for me. Monika32011 Programming 9 04-26-2011 08:05 AM
acroread command giving error iamjayanth Linux - Newbie 5 10-31-2008 08:36 AM
setup command giving error rishi_it Linux - Hardware 1 07-30-2008 08:11 AM
Slackware 10.0: Error message after giving startx command Fozmo Slackware - Installation 1 05-31-2006 09:38 PM
rpm command giving kernel error. dhruvypatel Mandriva 3 02-20-2006 10:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 10:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration