LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 05-15-2008, 03:50 PM   #1
noob_d
LQ Newbie
 
Registered: Apr 2008
Posts: 13

Rep: Reputation: 1
bizarre dial out issue - cant just dial a number then quit


First, yes, I am a noob. I touched on Linux a little over the years.I rencently got LFS 6.3 to fully go on a laptop (I even wrote scripts for the process), and I know some of the basic commands. For a new project, I used net-install Debian and got Nagios up and running.
What I am trying to accomplish as part of Nagios' notification process is to have the server simply dial a phone number, wait 30 seconds, then hang up (and exit the command invoking that process). The reason for this is so my boss and I wake up during the night to a ringing phone.
It seems as though every program I have got to successfully call out (wvdial, cu, pon) takes far too long to timeout and exit. I do not want any extra waiting or attempting ppp connections, so that Nagios can move on to the next notification command.
From what I can figure, those programs I mentioned previously all call to CHAT to actually dial. For the life of me, I cannot make CHAT dial the modem from the command line. I cannot figure out where to put ttyS0 in the command, or if it even uses it. Also, I attempted to use a chatscript and reference chat to it, but there is no details on where/how/if you add the port.
Does anyone have any ideas, or know how to make CHAT work from the command line? Any help is appreciated. If you need any more details, I will gladly provide them as best I can.
Thank you,
Darrell
 
Old 05-15-2008, 04:48 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 27,132
Blog Entries: 54

Rep: Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791Reputation: 2791
Quote:
Originally Posted by noob_d View Post
It seems as though every program I have got to successfully call out (wvdial, cu, pon) takes far too long to timeout and exit. I do not want any extra waiting or attempting ppp connections, so that Nagios can move on to the next notification command.
What you want is an asynchronous, external handler. Something like the handler below should work (I mean, it can't be simpler than that). What it does is tell 'at' to queue the command 'wvdialconf /etc/nagios/wvdial_mgr.conf' for immediate execution. The only thing *you* have to do is prep your wvdial or ppp or whatever else you use to dial out.

Code:
# "wvdial-a-manager" command definition
define command{
command_name wvdial-a-manager
command_line echo 'wvdialconf /etc/nagios/wvdial_mgr.conf'|at now
}
 
Old 05-15-2008, 06:45 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
As this seems to be the problem:
"takes far too long to timeout and exit" I can think of a couple of solutions.
In bash, you put the phone cmd into the background

# Phone_and_terminate script
#!/bin/bash
phone_script &
#$! is last background cmd pid
sleep 30
kill -9 $!

In Perl, you'd use wrap a SIGALRM around it
To interrupt a long-running operation, set a SIGALRM handler to call die. Set an alarm with alarm, then eval your code:
Code:
$SIG{ALRM} = sub { die "timeout" };

eval {
    alarm(3600);
    # long-time operations here
    alarm(0);
};

if ($@) {
    if ($@ =~ /timeout/) {
                            # timed out; do what you will here
    } else {
        alarm(0);           # clear the still-pending alarm
        die;                # propagate unexpected exception
    } 
}
 
Old 05-23-2008, 08:16 AM   #4
noob_d
LQ Newbie
 
Registered: Apr 2008
Posts: 13

Original Poster
Rep: Reputation: 1
Well, I have found that I can set the S7 register to a lower time in wvdial.conf and the modem will just give up and exit the program. I appreciate the help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why does my dial-up modem not have a dial tone on Mepis but does on Windows? (laptop) spirobulldog2004 MEPIS 10 10-28-2007 05:35 PM
incoming number not detecting in dial in server on fedora core3 binu_edl Linux - Software 0 10-24-2005 12:08 AM
Script to dial a number? shane.presley Linux - Networking 2 01-05-2005 01:08 PM
Cousin having trouble with dial up in kppp with SBC dial, please help Fear58 Linux - Networking 1 07-03-2004 09:11 PM
Setting-up dial-in & dial-up server in same machine sebastianjustin Linux - Networking 1 09-20-2003 02:35 PM


All times are GMT -5. The time now is 04:34 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration