login about faq

The following code stops after the first line in the file

while read f; do  
  ## calculate target directory  
  ssh -B -q user@server mkdir -p $DIR  
  echo $f  
  done < changes  

What do I have to do to get it to process multiple records?

asked Feb 16 '11 at 23:15

Marcus%20Vale's gravatar image

Marcus Vale
1111

edited Feb 18 '11 at 13:12

Roman's gravatar image

Roman ♦♦
7735817

If you comment out the ssh line does it still print all the lines in your input file (changes)?

(Feb 17 '11 at 19:48) Roman ♦♦ Roman's gravatar image

Try using the -n option to prevent it from reading from stdin. If the ssh command is requiring reading from stdin this could be causing your script to break out and fail.

Although it shouldn't if using batch mode (-B), since specifying this should cause the connection to fail if it required user interaction.

Most often this is because the server's hostkey has not been saved.

link

answered Feb 17 '11 at 20:10

Roman's gravatar image

Roman ♦♦
7735817

Yes, in fact, this is part of a much larger script and I isolated the problem down to this code by commenting things until I found what worked. -n did the trick.

link

answered Feb 17 '11 at 21:39

Marcus%20Vale%201's gravatar image

Marcus Vale 1
1

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×2

Asked: Feb 16 '11 at 23:15

Seen: 2,515 times

Last updated: Apr 01 '11 at 16:22

All user contributed content licensed under the cc-by-sa license.
Powered by OSQA.