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 資訊 | |
---|---|
![]() 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 |