Why is the shell output txt file empty?

Viewed 22

Kindly assist. I am working on a script that will perform a telnet test to a specific ip address on a specific TCP port and below is my script.

#! /bin/sh

nc -z -v -w5 192.168.88.55 3389 | tee results.txt

During execution, a "results.txt" file is created but it is empty. I want it to have the output of the script after execution.

1 Answers

I have managed to resolve it by making the below modifications to the script

#! /bin/sh

nc -z -v -w5 192.168.88.55 3389 2>&1 | tee results.txt

sleep 5

exit

It is now able to write the output to the results.txt file.

Thank you.

Related