Solved

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

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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Suggested Solutions

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

770 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