Executing ssh command in a bash shell script within a loop?

Ssh is consuming stdin. Pass it -n to prevent this.

Up vote 1 down vote favorite 1 share g+ share fb share tw.

I'm trying to execute an ssh command within a a bash shell script that should perform the following: 1) ssh to host 2) execute command 3) print value of command 4) repeat steps 1 -3 5) exit bash shell script I have set up password less entry to the remote host, added host key to remote host I want to test the various states of the httpd process running on the remote host Within a text file, httpd_process. Txt, I have: /etc/init. D/httpd status (stop, start, restart) I do the following in the script: while read LINE do echo "Httpd Request: $LINE" status=`$LINE` echo "Status: $status" sleep 5 # sleep so that next done Txt exit 0 I assumed that each time through the loop another input string is read from the input text file and the request is made to the remote host.

However, what I experience is that after the first request the script terminates. Am I correct to assume that as the first request is sent it creates a child process and once that process completes my script completes and the next turn through the loop is not executed? Bash ssh link|improve this question edited Jun 14 '11 at 22:43miku32.3k84074 asked Jun 14 '11 at 22:42Roland61.

Thanks, that worked great. I read about the different flags ssh command uses but I thought the -n flag is only used when running the ssh command in the background, and looking at my script, I did not specifically run the command in the background? – Roland Jun 14 '11 at 22:48 It must be used when ssh is run in the background.

It can be used when ssh is running in the foreground. – Ignacio Vazquez-Abrams Jun 14 '11 at 22:50.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions