Fix more I/O redirection issues.

Various command invocations in autotest use the bash-specific I/O
redirection syntax '&>', which doesn't work when dash is used. Under
dash, `ls foo &> /dev/null` is executed as `ls foo &` and `> /dev/null`
separately. As the latter always returns 0, the actual exit status of
the whole command isn't correctly determined.

This CL fixes the issues by using '>file 2>&1' instead.

BUG=chromium:458678
TEST=Manually going through the code.

Change-Id: I7dd22a5e898a18c7ff3d2fb43714e985eaa05c99
Reviewed-on: https://chromium-review.googlesource.com/249996
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
diff --git a/client/common_lib/cros/virtual_ethernet_pair.py b/client/common_lib/cros/virtual_ethernet_pair.py
index e28fd66..6df4191 100644
--- a/client/common_lib/cros/virtual_ethernet_pair.py
+++ b/client/common_lib/cros/virtual_ethernet_pair.py
@@ -221,14 +221,14 @@
                   ignore_status=self._ignore_shutdown_errors)
         self._run('ifconfig %s down' % self._peer_interface_name,
                   ignore_status=self._ignore_shutdown_errors)
-        self._run('ip link delete %s &> /dev/null ' % self._interface_name,
+        self._run('ip link delete %s >/dev/null 2>&1' % self._interface_name,
                   ignore_status=self._ignore_shutdown_errors)
 
         # Under most normal circumstances a successful deletion of
         # |_interface_name| should also remove |_peer_interface_name|,
         # but if we elected to ignore failures above, that may not be
         # the case.
-        self._run('ip link delete %s &> /dev/null ' %
+        self._run('ip link delete %s >/dev/null 2>&1' %
                   self._peer_interface_name, ignore_status=True)
 
 
@@ -238,7 +238,7 @@
         fake IP address.
         """
         self._run('ip link add name %s '
-                  'type veth peer name %s &> /dev/null ' %
+                  'type veth peer name %s >/dev/null 2>&1' %
                   (self._interface_name, self._peer_interface_name))
         self._run('ip link set %s up' % self._interface_name)
         self._run('ip link set %s up' % self._peer_interface_name)
diff --git a/client/cros/chrooted_avahi.py b/client/cros/chrooted_avahi.py
index 6a587b8..eff5eba 100644
--- a/client/cros/chrooted_avahi.py
+++ b/client/cros/chrooted_avahi.py
@@ -146,7 +146,7 @@
         self._chroot.add_copied_config_files(['etc/resolv.conf',
                                               'etc/avahi/hosts'])
         self._chroot.add_startup_command(
-                '/usr/sbin/avahi-daemon --file=/%s &> %s' %
+                '/usr/sbin/avahi-daemon --file=/%s >%s 2>&1' %
                 (self.AVAHI_CONFIG_FILE, self.AVAHI_LOG_FILE))
         self._chroot.bridge_dbus_namespaces()
         self._chroot.startup()
diff --git a/client/tests/kvm/tests/virtio_console.py b/client/tests/kvm/tests/virtio_console.py
index 07c502a..a9e980c 100644
--- a/client/tests/kvm/tests/virtio_console.py
+++ b/client/tests/kvm/tests/virtio_console.py
@@ -1257,7 +1257,7 @@
             on_guest("virt.close('%s')" % (port.name), vm, 2)
             on_guest("virt.open('%s')" % (port.name), vm, 2)
             try:
-                os.system("dd if=/dev/random of='%s' bs=4096 &>/dev/null &"
+                os.system("dd if=/dev/random of='%s' bs=4096 >/dev/null 2>&1 &"
                           % port.path)
             except:
                 pass
diff --git a/server/autoupdate_utils.py b/server/autoupdate_utils.py
index a14fe95..1341b0b 100644
--- a/server/autoupdate_utils.py
+++ b/server/autoupdate_utils.py
@@ -47,7 +47,7 @@
         logging.info('Starting devserver...')
 
         opts = '--image %s' % image_path
-        cmd = 'python devserver.py %s &>%s &' % (opts, DEVSERVER_LOG)
+        cmd = 'python devserver.py %s >%s 2>&1 &' % (opts, DEVSERVER_LOG)
         logging.info('devserver cmd: %s' % cmd)
 
         try:
diff --git a/server/cros/network/netperf_runner.py b/server/cros/network/netperf_runner.py
index 4498a78..d741968 100644
--- a/server/cros/network/netperf_runner.py
+++ b/server/cros/network/netperf_runner.py
@@ -500,8 +500,8 @@
     def __enter__(self):
         logging.info('Starting netserver...')
         self._kill_netserv()
-        self._server_host.run('%s -p %d &> /dev/null' % (self._command_netserv,
-                                                         self.NETPERF_PORT))
+        self._server_host.run('%s -p %d >/dev/null 2>&1' %
+                              (self._command_netserv, self.NETPERF_PORT))
         startup_time = time.time()
         self._client_proxy.firewall_open('tcp', self._server_proxy.wifi_ip)
         self._client_proxy.firewall_open('udp', self._server_proxy.wifi_ip)
diff --git a/server/site_linux_router.py b/server/site_linux_router.py
index 65b1da8..9e8dddc 100644
--- a/server/site_linux_router.py
+++ b/server/site_linux_router.py
@@ -906,7 +906,7 @@
 
         # Connect the station.
         self.router.run('%s link set %s up' % (self.cmd_ip, interface))
-        start_command = ('%s -dd -t -i%s -P%s -c%s -D%s &> %s &' %
+        start_command = ('%s -dd -t -i%s -P%s -c%s -D%s >%s 2>&1 &' %
                          (self.cmd_wpa_supplicant,
                          interface, pid_file, conf_file,
                          self.HOSTAPD_DRIVER_NAME, log_file))
@@ -970,4 +970,4 @@
                 self.get_virtual_ethernet_master_interface())
         # Add peer interface to the bridge.
         self.add_interface_to_bridge(
-                self.get_virtual_ethernet_peer_interface())
\ No newline at end of file
+                self.get_virtual_ethernet_peer_interface())