bash while break

Try continue instead of done . That takes you to the next iteration of the loop., You set rc=$? before the ssh command,...

bash while break

Try continue instead of done . That takes you to the next iteration of the loop., You set rc=$? before the ssh command, and the last command was the test ( [ ) command, which just succeeded, so when you test if [[ $rc -eq 0 ]] the answer is always 'yes, it does'. It's best to test the status of ssh directly: #!/bin/bash it

相關軟體 PuTTY 資訊

PuTTY
PuTTY 是一個免費的 Windows 和 Unix 平台的 Telnet 和 SSH 實現,以及一個 xterm 終端模擬器。它主要由 Simon Tatham 編寫和維護. 這些協議全部用於通過網絡在計算機上運行遠程會話。 PuTTY 實現該會話的客戶端:會話顯示的結束,而不是運行結束. 真的很簡單:在 Windows 計算機上運行 PuTTY,並告訴它連接到(例如)一台 Unix 機器。 ... PuTTY 軟體介紹

bash while break 相關參考資料
bash - Break out of if statement in while loop - Stack Overflow

This is actually pretty simple using the return built-in. Inside the while loop, set the if statement inside a small function block. When the if condition is met during the iterations, you can have i...

https://stackoverflow.com

bash while break out of cycle not loop? - Stack Overflow

Try continue instead of done . That takes you to the next iteration of the loop.

https://stackoverflow.com

Bash while loop - break and exit (DIE script DIE!!!) - Stack Overflow

You set rc=$? before the ssh command, and the last command was the test ( [ ) command, which just succeeded, so when you test if [[ $rc -eq 0 ]] the answer is always 'yes, it does'. It's ...

https://stackoverflow.com

Break and continue

bin/bash # This script provides wisdom # You can now exit in a decent way. FORTUNE=/usr/games/fortune while true; do echo "On which topic do you want advice?" echo "1. politics" ec...

http://tldp.org

Break and Continue in Bash For Loop - Geeking

How to break a bash for loop, and how to continue the loop.

https://www.garron.me

Loop Control

The break command terminates the loop (breaks out of it), while continue causes a jump to the next iteration of the loop, skipping all the remaining commands in that particular loop cycle. Example 11-...

http://tldp.org

shell - How to break out of a loop in Bash? - Stack Overflow

It's not that different in bash . done=0 while : ; do ... if [ "$done" -ne 0 ]; then break fi done. : is the no-op command; its exit status is always 0, so the loop runs until done is g...

https://stackoverflow.com

The while loop

bin/bash # This script copies files from my homedirectory into the webserver directory. # (use scp and SSH keys for a remote directory) # A new directory is created every hour. PICSDIR=/home/carol/pic...

http://tldp.org