Created
March 12, 2020 00:00
-
-
Save craigvantonder/e8a071694ea94a2958cbb056657eb261 to your computer and use it in GitHub Desktop.
Two ways to check if a SSH control socket is open in BASH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# How can I fully log all bash scripts actions? | |
# https://serverfault.com/a/103569/210437 | |
if test -S "/absolute/path/to/ssh_control_socket"; then | |
echo 'It exists' | |
fi | |
# Why can't bash recognize the existence of a socket file | |
# https://stackoverflow.com/a/37618542/2110294 | |
TEST=`ssh -o ControlPath=ssh_control_socket -O check anything_but_required` | |
if [ "$TEST" = *"Master running"* ]; then | |
echo 'It exists' | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment