1

I have a very limited list of software that I can install on an (IOT edge) device. I have minicom and chat commands (in addition to standard commands like echo and cat), and need to write to a serial device a command and read the response.

The device in question is a modem, and I need to run AT commands on it. If using minicom and setting up the menu etc. I can run these commands normally, and get the output. The problem is that I have around a thousand of these devices, so setup and data logging needs to be automated.

So within these parameters is there a way to run minicom and capture the output without any interactive elements? I have tried

minicom -S scriptfile -C outfile

where scriptfile (for now) contains following:

sleep 1
send "AT"

This seems to ignore the sleep command, and outfile is created, but is left empty. Also what would I need to add to the command that it wouldn't open a session or interactive element?

Nyxeria
  • 363
  • 1
  • 4
  • 12
  • If your system does indeed have [the powerful `expect` command](https://en.wikipedia.org/wiki/Expect), then its options are not "very limited". – agc Mar 10 '21 at 16:25
  • I'm not sure it actually has expect, as the script does not run, or even obey the command sleep. The limitation is that I cannot install almost anything on the boxes, as they are in a private network, and I don't have control over the repo. It was a pain to get even openssl on the box. – Nyxeria Mar 11 '21 at 07:26
  • What happens when you run `expect -c 'send "hello world\r"'` on the system in question? – agc Mar 11 '21 at 22:17
  • It prints: `-ash: expect: not found` – Nyxeria Mar 12 '21 at 13:31
  • Apparently the system in question does not have `expect`. Please modify the question to remove all mentions of `expect`. – agc Mar 12 '21 at 22:12
  • Typically `chat` as in `man 8 chat` is used to automate talking to a modem. – KamilCuk Mar 13 '21 at 00:24

1 Answers1

0

So within these parameters is there a way to run minicom and capture the output without any interactive elements?

I am not sure about minicom, but I have a better tool for this job which was written specifically for the purpose to being able to run AT commands non-interactive from the command line with capture capabilities: atinout.

You can automate this in any way you like, for instance

for device in mydevice0001 mydevice0002 ... mydevice1000
do
    atinout my_at_commands.txt /dev/$device capture-$device.txt
done
hlovdal
  • 26,565
  • 10
  • 94
  • 165