Amir Afghani
Amir Afghani

Reputation: 38561

netcat script to send a message to a marquee device

I wrote a script that uses netcat to update the marquee in my office without knowing the ip address of the device. I used fping to calculate candidateIPs.

The script works. But, I still don't know the IP address of the device. Can someone help me understand how to update the script to narrow down the IP address that updated the text on the device?

#!/bin/bash

while read p; do
   echo "try $p"
   echo "\x00\x00\x00\x00\x00\x01\x5A\x30\x30\x02\x41\x41\x1B\x22\x61 Test message!\x04" | nc $p 3001 &
done < candidateIPs

wait

Upvotes: 0

Views: 225

Answers (1)

konsolebox
konsolebox

Reputation: 75588

You can log your outputs an add verbosity e.g.

#!/bin/bash

while read p; do
   echo "try $p"
   echo "\x00\x00\x00\x00\x00\x01\x5A\x30\x30\x02\x41\x41\x1B\x22\x61 Test message!\x04" | nc -v "$p" 3001 2>&1 | tee "$p.log" &
done < candidateIPs

wait

You can examine either the ip-specific log files after that.

Upvotes: 1

Related Questions