Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

Loop not iterating.

Here you can discuss every aspect of Debian. Note: not for support requests!
Post Reply
Message
Author
Munty Scruntfundle
Posts: 54
Joined: 2018-11-27 16:53

Loop not iterating.

#1 Post by Munty Scruntfundle »

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.

#2 Post by Munty Scruntfundle »

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.

#3 Post by Munty Scruntfundle »

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.

#4 Post by Munty Scruntfundle »

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?

Post Reply