Interrupting watch if command execution was successful
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I would like to be able to interrupt watch if execution of command was successful. In effect, I'm looking for a reverse behaviour than that offered via --errexit
. As per man:
-e
,--errexit
Freeze updates on command error, and exit after a key press.
Example
The command:
ping -c 3 www.google.com
Fails due to the patchy connection*. I can re-run in the following manner to see when the connection is back:
watch -n 1 'ping -c 3 www.google.com'
I would like to stop watch if ping
executes with no error.
* I'm not looking to find a better of way of verifying connectivity. The ping
examples comes from using a mobile phone connection when on the train with mobile phone loosing signal every so often.
bash watch
add a comment |Â
up vote
2
down vote
favorite
I would like to be able to interrupt watch if execution of command was successful. In effect, I'm looking for a reverse behaviour than that offered via --errexit
. As per man:
-e
,--errexit
Freeze updates on command error, and exit after a key press.
Example
The command:
ping -c 3 www.google.com
Fails due to the patchy connection*. I can re-run in the following manner to see when the connection is back:
watch -n 1 'ping -c 3 www.google.com'
I would like to stop watch if ping
executes with no error.
* I'm not looking to find a better of way of verifying connectivity. The ping
examples comes from using a mobile phone connection when on the train with mobile phone loosing signal every so often.
bash watch
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I would like to be able to interrupt watch if execution of command was successful. In effect, I'm looking for a reverse behaviour than that offered via --errexit
. As per man:
-e
,--errexit
Freeze updates on command error, and exit after a key press.
Example
The command:
ping -c 3 www.google.com
Fails due to the patchy connection*. I can re-run in the following manner to see when the connection is back:
watch -n 1 'ping -c 3 www.google.com'
I would like to stop watch if ping
executes with no error.
* I'm not looking to find a better of way of verifying connectivity. The ping
examples comes from using a mobile phone connection when on the train with mobile phone loosing signal every so often.
bash watch
I would like to be able to interrupt watch if execution of command was successful. In effect, I'm looking for a reverse behaviour than that offered via --errexit
. As per man:
-e
,--errexit
Freeze updates on command error, and exit after a key press.
Example
The command:
ping -c 3 www.google.com
Fails due to the patchy connection*. I can re-run in the following manner to see when the connection is back:
watch -n 1 'ping -c 3 www.google.com'
I would like to stop watch if ping
executes with no error.
* I'm not looking to find a better of way of verifying connectivity. The ping
examples comes from using a mobile phone connection when on the train with mobile phone loosing signal every so often.
bash watch
bash watch
asked Aug 15 at 16:33
Konrad
1797
1797
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Since you would start receiving pings once your network connection has been restored, start the watch
after your connection has dropped and tell it to exit once the output changes:
watch -g -n 1 ping -c 3 www.google.com
As soon as you start receiving pongs, watch will exit.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Since you would start receiving pings once your network connection has been restored, start the watch
after your connection has dropped and tell it to exit once the output changes:
watch -g -n 1 ping -c 3 www.google.com
As soon as you start receiving pongs, watch will exit.
add a comment |Â
up vote
1
down vote
accepted
Since you would start receiving pings once your network connection has been restored, start the watch
after your connection has dropped and tell it to exit once the output changes:
watch -g -n 1 ping -c 3 www.google.com
As soon as you start receiving pongs, watch will exit.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Since you would start receiving pings once your network connection has been restored, start the watch
after your connection has dropped and tell it to exit once the output changes:
watch -g -n 1 ping -c 3 www.google.com
As soon as you start receiving pongs, watch will exit.
Since you would start receiving pings once your network connection has been restored, start the watch
after your connection has dropped and tell it to exit once the output changes:
watch -g -n 1 ping -c 3 www.google.com
As soon as you start receiving pongs, watch will exit.
answered Aug 15 at 16:52
Jeff Schaller
32.6k849110
32.6k849110
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462784%2finterrupting-watch-if-command-execution-was-successful%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password