LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-15-2011, 01:17 PM   #1
gburton
LQ Newbie
 
Registered: Jun 2011
Posts: 3

Rep: Reputation: Disabled
While loop in SSH command


I am having trouble getting the while loop to execute in the ssh command:

ssh $USERID@serverX "while read line do echo $line done<$list_dir/cost_feed.lst.old"

Error: bash: -c: line 1: syntax error: unexpected end of file

I have managed to use simpler commands with ssh like:
ssh $USERID@serverX "pwd; cp x y"

I expect that I need to add some combination of escape characters or semicolons, but if anyone can point me in the right direction, i would appreciate it.
 
Old 06-15-2011, 01:23 PM   #2
Skaperen
Senior Member
 
Registered: May 2009
Location: WV, USA
Distribution: Slackware, Ubuntu, Amazon Linux
Posts: 1,830
Blog Entries: 21

Rep: Reputation: 119Reputation: 119
You need a couple semicolons in the right places:

Code:
ssh $USERID@serverX "while read line; do echo $line; done<$list_dir/cost_feed.lst.old"
 
Old 06-15-2011, 01:32 PM   #3
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978Reputation: 1978
I'd also change the double quotes with single quotes to protect the $ sign from the local shell.
 
Old 06-15-2011, 02:29 PM   #4
gburton
LQ Newbie
 
Registered: Jun 2011
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks, that worked.
 
  


Reply


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
[SOLVED] ssh command in a loop ? gadikota Linux - Newbie 3 01-04-2011 10:06 PM
SSH onto nodes in a loop and then get off MOFH Linux - Newbie 2 11-20-2009 10:41 AM
ssh program for a loop g4gopal@yahoo.com Programming 1 01-26-2009 06:13 PM
SSH Bash Loop m1ck Programming 7 01-31-2007 10:03 AM
while loop failure due to ssh hurny^ Programming 1 05-04-2004 03:00 PM


All times are GMT -5. The time now is 05:10 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration