It would be real easy if your dialer script, used Tk, Gtk2, POE, or some other event loop system. Why? Because you need to do 2 things at once, dial, and monitor for a key.

For example, if you look at the following loop, a 'q' will stop it, but the 'print' is fast and the loop will be looping fast checking for the 'q'. In your case, if you try dialing instead of printing, the loop will not proceed, while the dial sub is running.

#!/usr/bin/perl use Term::ReadKey; $char='q'; while(1){ ReadMode ('cbreak'); if (defined ($ch = ReadKey(-1))){ #input was waiting and it was $ch if ($ch eq $char){exit(0);} }else{ # no input was waiting #your program goes here print "############################\n"; select(undef,undef,undef,.01); } ReadMode ('normal'); # restore normal tty settings } __END__

Now if you have an event lopp, like this Tk program, the dial can proceed, and you can interrupt it with a key press. This is just pseudo code, because I don't have the code you are using, but it should give you the idea.

#!/usr/bin/perl use warnings; use strict; use Tk; #use Device::Modem; #my $modem = new Device::Modem( log =>'file,modemlog',port => '/dev/tt +yS1' ); my $mw = MainWindow->new; $mw->Label( -text => 'press q to quit dial' )->pack; $mw->Button(-text=> 'Start Dial', -command => \&start_dial )->pack; $mw->Button(-text=> 'Quit', -command => \&exit )->pack; $mw->bind( '<q>' => \&stop_dial ); MainLoop; sub start_dial{ print "dial started\n"; #you would do something like #$modem->dial('123-456-2345'); } ############################ sub stop_dial { print "q pressed\n"; # do something like # $modem->reset(); } __END__

There are other Event modules, search cpan for them, or look at Roll your own Event-loop for ideas which will let you do it from a commandline script, without a GUI.


I'm not really a human, but I play one on earth. flash japh

In reply to Re: Device::Modem Help by zentara
in thread Device::Modem Help by strange1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.