Solved

How to test if a modem is on/off inside a script?

Posted on 2002-07-25
4
291 Views
Last Modified: 2010-04-21
Hi,
I need to test inside a shell script (UX10.20) is a modem is on/off. If it is off, I have to do some actions (Send an email...).
That script will b excuted via cron, every minute.
1. What is the command to check the modem on/off? (Is it cu -l /dev/... ? )
    How do I do it inside a script??
2. If u can, provide me the full script. It has to do a very simple action:
   Check if the modem is active (On electricity...), if not send an email to some people.
   
Many thanks, leee
0
Comment
Question by:leeee
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 6

Accepted Solution

by:
bira earned 400 total points
ID: 7177692
Hi
  Suppose your modem is identified by tty1.

    Run the script below:

test=`cu -l /dev/tty1 2>/dev/null`
if [ $? = 0 ] ; then
     echo "Contact with the modem OK."
      else
     echo "Contact failed."
    # at this point place the send mail command...
fi
0
 
LVL 1

Expert Comment

by:dkloes
ID: 7198184
bira:

I don't have a system handy at the moment to see if cu has any standard output.  If so, maybe:

test=`cu -l /dev/tty1 > /dev/null 2>&1`

If not, ignore my comment.
0
 
LVL 21

Expert Comment

by:tfewster
ID: 7921687
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by bira

Please leave any comments here within the next 7 days

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

tfewster
Cleanup Volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7967253
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question