Roger Bowler’s Unix Tips for z/OS systems programmers

Index

Unix Tips

How to set the Title Bar in an Xterm window
Add the following lines to .bash_profile in your home directory:
if [ "${TERM}" = "xterm" ]; then
  PROMPT_COMMAND='echo -ne "\033]0;${HOSTNAME%%.*}:${LOGNAME}\007"'
fi
How to test the exit status of a pipe
The bash shell uses the exit status of the last command in the pipeline as the exit status of the entire pipeline. The other statuses are available via the PIPESTATUS variable, which is an array variable containing the exit statuses of all of the commands in the pipeline. Example:
   command1 | command2
   if [ "${PIPESTATUS[@]}" != "0 0" ]
   then
      echo "*** ERROR ***"
   fi

Thanks to Chet Ramey for this tip

How to fix VirtualBox duplicate ping with a bridged network adapter
The symptoms of the problem are that machines on the network outside of the VirtualBox host are unable to access a VirtualBox guest whose network adapter is defined as bridged, and the guest cannot access any machine except the VirtualBox host. Ping returns duplicate response messages like this:
PING 192.168.1.110 (192.168.1.110) 56(84) bytes of data.
64 bytes from 192.168.1.110: icmp_seq=1 ttl=64 time=1.58 ms
64 bytes from 192.168.1.110: icmp_seq=1 ttl=63 time=1.58 ms (DUP!)
64 bytes from 192.168.1.110: icmp_seq=2 ttl=64 time=3.94 ms
64 bytes from 192.168.1.110: icmp_seq=2 ttl=63 time=3.94 ms (DUP!)
64 bytes from 192.168.1.110: icmp_seq=3 ttl=64 time=5.24 ms
64 bytes from 192.168.1.110: icmp_seq=3 ttl=63 time=5.24 ms (DUP!)
The solution is to disable IP forwarding on the VirtualBox host:
   sudo sysctl -w net.ipv4.ip_forward=0
To ensure that the setting is preserved across reboots, create a file named /etc/sysctl.d/85-virtualbox.conf containing this:
# Turn off IP forwarding to prevent VirtualBox duplicate response to ping
net.ipv4.ip_forward=0
https://www.virtualbox.org/ticket/9648 suggests that the problem would be fixed in 2011 by VirtualBox 4.1.6, but this appears not to be the case.


Last updated 25 Feb 2024