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
Solved

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

Posted on 2002-07-25
4
282 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
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 20

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

860 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