I have a 1 liner that will write the output of a telnet session to a file.
while sleep 5; do sleep 1 | telnet 11.22.33.44 443 | tee -a /var/tmp/test$(date +%Y%m%d).txt && date >> /var/tmp/test$(date +%Y%m%d).txt; done &
I do not want to see the output from the first command however would like to run this 1 liner and show the output:
awk '!/Trying/{count++}/Trying/{if (count == 4) print "Connected"; else if (count == !NR) print ""; else print "Failed"; count = 0}' test$(date +%Y%m%d).txt
Bonus if ! can get both in 1 line to show output as below:
while sleep 5; do sleep 1 | telnet 159.203.162.223 443 | tee -a /var/tmp/test$(date +%Y%m%d).txt && date >> /var/tmp/test$(date +%Y%m%d).txt; done & awk '!/Trying/{count++}/Trying/{if (count == 4) print "Connected"; else if (count == !NR) print ""; else print "Failed"; count = 0}' test$(date +%Y%m%d).txt
Connected
Connected
Connected
Connected
Connected
Connected
Connected
Connected
Connected
Connected