Operating System - HP-UX
1830945 Members
2067 Online
110017 Solutions
New Discussion

write a script to check the status of modem?

 
Grace Li
Frequent Advisor

write a script to check the status of modem?

I have a modem connected to HP-UX 11i. It only transmits data out, sometimes it fails. I need to write a scipt to check if the modem is ready or broken. I can write a shell script and put it on cron (runs every 15 minutes). I am looking for the command to check the status of the modem device. Can anyone please help?
10 REPLIES 10
Steven Schweda
Honored Contributor

Re: write a script to check the status of modem?

You could use "expect" or Kermit to send one
or more commands to the modem. What to send
and what to look for in the response may
depend on the type of modem and its
configuration.

> [...] sometimes it fails.

Fails how?

If it fails in an unpredictable way, it could
also fail immediately after your script tests
it, so why bother testing it?. It might make
more sense to improve the error handling in
the real application which uses the modem, so
that something appropriate is done when it
fails.

Or get a more reliable modem.
Grace Li
Frequent Advisor

Re: write a script to check the status of modem?

thanks steven. the idea is to put a monitor in place to pull the status of it. and then when it fail, the script can capture the error message. we can go futher to fix the problem. What unix command to check the modem? Any idea?
Steven Schweda
Honored Contributor

Re: write a script to check the status of modem?

> What unix command to check the modem?

None. You need to talk to it (and listen to
it). Perhaps if you say "ATE1Q0V1",
it will say "OK". And perhaps that will mess
up its configuration, so you might also say
something like "ATZ" to reset it. Or
perhaps something entirely different,
depending on the modem.

> [...] Any idea?

Same as before. Read it again. Or did you
want me to write a script to do the job for
you, knowing nothing about the available
communication software ("expect", Kermit,
...), and nothing about the modem or its
configuration, either?

You might start by reading the manual for the
modem.

If you don't know what causes the failure, it
can, as I said before, fail between when you
test it and when you need it, so testing it
this way really is the wrong way to approach
the problem.
A. Clay Stephenson
Acclaimed Contributor

Re: write a script to check the status of modem?

This is one of those "it depends" situations. It largely depends upon how the modem is connected and the type of modem. For example if hardware handshake is enabled you have to handle the RTS/CTS protocol which means that you have to force a line on before communication can take place. You really haven't provided enough data. For modems that use the old Hayes AT commands then all you have to do is send "AT" to the port and then the modem will respond with "OK" ---- if the modem is configured to do so.
If it ain't broke, I can fix that.
Grace Li
Frequent Advisor

Re: write a script to check the status of modem?

I can use the "cu -l -s dir" to connect to the modem and then "at" it returns "OK". The problem is I can not exit out. This is interactive mode, I want to put the check in a unix scipt.
Steven Schweda
Honored Contributor

Re: write a script to check the status of modem?

> You could use "expect" or Kermit to send one
> or more commands to the modem.

> communication software ("expect", Kermit,
> ...),

Do you ever read these responses?
Grace Li
Frequent Advisor

Re: write a script to check the status of modem?

how to put that in a shell script?
Grace Li
Frequent Advisor

Re: write a script to check the status of modem?

Thanks Steven. Is "expect" a utility of HP-UX? Or, a 3rd party software? Do you know of the efax command? It is under /usr/local/bin/efax. Can it be used to poll the modem?
Steven Schweda
Honored Contributor

Re: write a script to check the status of modem?

> Is "expect" a utility of HP-UX? [...]

Google broken?

http://expect.nist.gov/
http://expect.nist.gov/FAQ.html

> Do you know of the efax command? It is
> under /usr/local/bin/efax.

If it's in /usr/local, then it's not likely
that it came with the OS, is it? I probably
wouldn't use a fax program to try to send a
simple command to a modem. But, for reasons
already given a couple of times, I also
wouldn't bother trying to test a modem this
way.
Grace Li
Frequent Advisor

Re: write a script to check the status of modem?

Thanks Steven. Now that hardware modem is not recommanded. what about checking the fax queue? Is there a command to check the fax, similar to print jobs?