==== RDP to Work with error checking ==== This little script reports back any issues it has along the way. It assumes that the VPN connection is named Work-VPN, and that the credentials are in ~/.netrc #!/usr/bin/bash # SRJ 2017-02-16-12-30 # This script calls an rdp client from the command line, pulling credentials # from ~/.netrc # The line below reads credentials into the Creds array, useful # data is in the odd references, the keys are in the evens. Creds=($(grep -A 2 "machine Work" ~/.netrc)) if [ $? ] ; then echo "Can't read credentials" exit 2) fi # Test the network ping -c2 8.8.8.8 > /dev/null if [ $? ] ; then echo "Can't ping out" exit 2 fi # Bring up the VPN nmcli con up Work-VPN if [ $? ] ; then echo "Can't bring up the VPN" exit 2 fi # Can we ping ADB? ping -c2 10.0.0.150 > /dev/null if [ $? ] ; then echo "Can't ping ADB" exit 2 fi # Connect to RDP with the creds from above. xfreerdp /f /sound /microphone /multimon /d:WorkDomain /u:${Creds[3]} \ /p:"${Creds[5]}" /v:sjones-pc.WorkDomain.net # Drop the VPN connection nmcli con down Work-VPN if [ $? ] ; then echo "Can't bring down the VPN" exit 2 fi And in ~/.netrc cat ~/.netrc machine Work user SteveJ password Pests%Hello5Morns