Loop not iterating.

Here you can discuss every aspect of Debian. Note: not for support requests!

Loop not iterating.

Postby Munty Scruntfundle » 2019-02-11 18:16

Hi folks.

I have the following little bit of bash which appears to be working, the first ip address in the file is echoed and then I get 'hello' echoed from the ssh command. But that's it, it doesn't iterate the file.

If I take out the ssh it does. So I'm guessing its something to do with a new wheel being opened, then when it closes the loop gets cut. Could someone please explain why this happens and what I need to do to get the loop running?

Many thanks.

Code: Select all
while read line; do
        echo $line
        ssh pi@$line echo hello
done </mybin/nodes
Munty Scruntfundle
 
Posts: 54
Joined: 2018-11-27 16:53

Re: Loop not iterating.

Postby Munty Scruntfundle » 2019-02-11 18:17

I put 'shell' in front of the ssh, and that seems to have fixed it.

Sorry for the false alarm!
Munty Scruntfundle
 
Posts: 54
Joined: 2018-11-27 16:53

Re: Loop not iterating.

Postby Munty Scruntfundle » 2019-02-11 18:24

However...

While I get a simple echo back the following fails with 'command not found', but I don't know which bit is failing.

Code: Select all
shell ssh pi@$line 'nohup blender -b /raider.blend -a >>/dev/null 2>&1 &'


Any ideas?

Thanks.
Munty Scruntfundle
 
Posts: 54
Joined: 2018-11-27 16:53

Re: Loop not iterating.

Postby Munty Scruntfundle » 2019-02-11 18:57

I found this approach in a thread on Stack.

Code: Select all
if ssh pi@$line 'nohup blender -b /raider.blend -a >>/dev/null 2>&1 &'  </dev/null; then


Why does sending in a null make the command behave with an exit I can then check?
Munty Scruntfundle
 
Posts: 54
Joined: 2018-11-27 16:53


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable