I am trying to pull temperature and humidity data from Fluke DewK 1620a thermo-hygrometers and write the temp/humidity readings to a log. I can connect to the device via netcat with a simple 'nc 10001', run some basic commands and receive output. Now I'd like to construct a command line, I can put in a script that will send a command and write the output to a file.

If I run the following from the command line

$ echo "read?" | nc -v -i 1 10001

I receive:

Connection to 10001 port [tcp/scp-config] succeeded!

After the -i interval has elapsed, the connection closes and my prompt overwrites the temperature and humidity data.

I then tried the following:

echo "read?" | nc -v -i 1 10001 >> test.out 2>&1

The command executes and the 'test.out' file only contains the following for each execution.

Connection to 10001 port [tcp/scp-config] succeeded!

The temperature and humidity readings are not included in the file. Increasing the verbosity does not seem to help.

I know I'm probably missing something obvious, but I simply cannot see it. Any help would be greatly appreciated.


2 Answers 2


I don't see anything wrong which makes me wonder if your Fluke is actually responding.

These two netcat scripts show that there is nothing wrong with your syntax


# server
while true; do date; sleep 1; done | nc -l 10001


# client
echo "hello?" | nc -v -i1 localhost 10001 >> test.out 2>&1


[sri@tidevel netlink]$ cat test.out 
Ncat: Version 6.45 ( http://nmap.org/ncat )
Ncat: Connected to
Wed Nov  5 13:54:06 EST 2014
Wed Nov  5 13:54:07 EST 2014
Ncat: Idle timeout expired (1000 ms).

So, since all that works verify that your are actually getting responses from the Fluke. Maybe there is another netcat or other application that is consuming the Fluke data?

Maybe the command needs to be terminated by \r \n or something like like. I seem to remember that being the case for Thermotrons but it's been a long time. You can use printf to do that:

printf "hello?\r\n" | nc -v -i1 localhost 10001 >> test.out 2>&1
  • I believe the root issue (or complicating factor) is that there is no netcat running on the other side of the connection (on the Fluke). If I run the command I get the output in the shell, it just will not get dumped to the test.out. Printf doesn't seem to do it either, but then I think the problem is on the redirected output side of the command.
    – DFarland
    Commented Nov 6, 2014 at 20:34

I'm not sure I'd call it an "answer" per se, but I was able to approximate what I was looking to do in a completely different way. Instead of nc, I've managed to get further along using a file descriptor on /dev/tcp.

exec 3<>/dev/tcp/${host}/${port}
echo -e "read?" >&3
cat <&3 | tee -a ${log}
exec 3<&-
exec 3>&-

There are still some issues I need to work out with this approach, but I am able to pull the data I need and get it into a log file. I'll try another post later if I can't figure out my niggling issues with this method myself.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .