Hi
The $(...) does not capture stderr output.
Could you use ping exit code directly; it will fail in it got no
repllies.
--
mr. M01510 & guide Loadstone-GPS
Lat: 62.38718, lon: 25.64672
hkp://wwwkeys.pgp.net B784D020
0C1F 6A76 DC9D DD58 3383 8B5D 0E76 9600 B784 D02
Jude DaShiell kirjoitti
Subject: network script syntax problem
Date: Fri, 6 Nov 2015 07:08:46 -0500 (EST)
From: Jude DaShiell <jdashiel@xxxxxxxxx>
To: blinux-list@xxxxxxxxxx
#!/usr/bin/env bash
# file: $0 - script to find useable connection on hughsnet.
let CONNECT=0
while [ $CONNECT -lt 1 ]; do
sudo -H dhcpcd -k 2>&1 >/dev/null
sudo -H dhcpcd
ST=$( ping -c 5 8.8.8.8|tail -2 )
if [ $ST !='connect: Network is unreachable' ]; then
CONNECT=CONNECT+1
fi
done
The ST variable doesn't capture the search string the if statement is needing
to find. Putting parentheses around a command appears only to capture output
of a command and send it to stdout or stderr. In case of bad network
connections this script first kills dhcp then reconnects. If successful it
need only happen once.
--
_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list
_______________________________________________
Blinux-list mailing list
Blinux-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/blinux-list