I quite this script in bash:
probe='nc -zv localhost 19997' output=' grep -c 'succeeded' $probe' if [ $output == '0' ] then echo 'Client online' else echo 'Offline' fi
The purpose of the script is to check via netcat if a client connected via reverse ssh to my server on port 19997 and print a positive message if this was detectet. nc would print
Connection to localhost 19997 port [tcp/*] succeeded!
if it detects the client and I would like to grep only the 'succeeded' as a keyword for the established connection and trigger the if-statement via the exit code of grep. But when i run this script I get:
test.sh: line 3: [: too many arguments
Where did I do wrong?