recover_duts: fix awk error due to line break
Despite being invoked by the shell, awk isn't seeing the second
part of the line;
awk: cmd. line:1: /tcp.*:22 .*ESTABLISHED.*/ { split($5,a,":") ;
awk: cmd. line:1: ^
unexpected newline or end of string
Fix is to append '\' to the offending line to tell the shell
both lines should be passed to awk together.
BUG=none
TEST=invoke /usr/local/bin/hook/check_ethernet.hook from console
when no SSH connections are present.
Confirm output does not include awk syntax error.
Change-Id: I26c1de6509c8811bb93585d40fb94259998d1ccf
Reviewed-on: https://chromium-review.googlesource.com/1123693
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Kirtika Ruchandani <kirtika@chromium.org>
Tested-by: Grant Grundler <grundler@chromium.org>
Reviewed-by: Kirtika Ruchandani <kirtika@chromium.org>
Reviewed-by: Grant Grundler <grundler@chromium.org>
diff --git a/recover_duts/hooks/check_ethernet.hook b/recover_duts/hooks/check_ethernet.hook
index a0209a4..6df1727 100755
--- a/recover_duts/hooks/check_ethernet.hook
+++ b/recover_duts/hooks/check_ethernet.hook
@@ -128,8 +128,8 @@
# Restart all our ethernet devices and restart shill.
# Return the remote IP address of the first established SSH connection
find_ssh_client() {
- netstat -lanp | awk '/tcp.*:22 .*ESTABLISHED.*/ {split($5,a,":"); '
- ' if (a[1] != "127.0.0.1") print a[1]}'
+ netstat -lanp | awk '/tcp.*:22 .*ESTABLISHED.*/ {split($5,a,":"); \
+ if (a[1] != "127.0.0.1") print a[1]}'
}
# Return the IP address of a neighbor reachable via ethernet