So I have a similar issue to this https://stackoverflow.com/questions/10172860/linux-script-to-parse-telnet-message-and-exit
I have a bash script
In that script I need to
* non interactively connect to TCP port localy.
* Store the strings that I get as I connect
* Compare that string with what I expect the answer to be.
Here is a solution that don't work:
#!/bin/bash
VALIDTELNET="parastat vdev"
# Test telnet
TELNET=$(echo | nc 127.0.0.1 22196)
if [[ "$TELNET" == "$VALIDTELNET" ]]
then
echo "Telnet Ok" ;
else
echo "Telnet connection test failed"
ERROR=22196
fi
--
I've also used telnet, curl, exec 3<>/dev/tcp/127.0.0.1/22196, etc.
I either have the string but it is interactive, or the connection stops, but I don't get the strings.
Note: Why bash, why not X?
I only want bash, because this is test script and I don't want to install more stuff during the test run.
Help appreciated :3