[Freeswitch-users] [Freeswitch-dev] How to check the "fax_result_code" in the script? such as php script?

Nathan Neulinger nneul at mst.edu
Thu Apr 17 16:09:14 MSD 2014


Only thing in there is a pair of routines to bump up the stack size limit to the hard limit:

---------------------------
#!/usr/bin/perl
use strict;
use BSD::Resource;

my $saved_stack = 0;
my $saved_stack_soft;
my $saved_stack_hard;

sub stack_max {
     my ( $rss_soft, $rss_hard ) = getrlimit("RLIMIT_STACK");
     if ( !$saved_stack ) {
         $saved_stack_soft = $rss_soft;
         $saved_stack_hard = $rss_hard;
         $saved_stack      = 1;
     }
     freeswitch::console_log( "info", "rlimit_stack ($rss_soft, $rss_hard)\n" );

     my $rstat = setrlimit( "RLIMIT_STACK", $rss_hard, $rss_hard );
     freeswitch::console_log( "info", "rlimit_stack set res = $rstat\n" );

     ( $rss_soft, $rss_hard ) = getrlimit("RLIMIT_STACK");
     freeswitch::console_log( "info", "rlimit_stack now ($rss_soft, $rss_hard)\n" );
}

sub stack_restore {
     if ($saved_stack) {
         my $rstat = setrlimit( "RLIMIT_STACK", $saved_stack_soft, $saved_stack_hard );
         freeswitch::console_log( "info", "rlimit_stack set res = $rstat\n" );

         my ( $rss_soft, $rss_hard ) = getrlimit("RLIMIT_STACK");
         freeswitch::console_log( "info", "rlimit_stack now ($rss_soft, $rss_hard)\n" );
     }
     else {
         freeswitch::console_log( "info", "rlimit_stack not saved, cannot restore\n" );
     }
}

1;
-------------------------------------



On 04/17/2014 03:47 AM, sparklezou wrote:
> Hi Nathan,
> Thanks very much!
> Could you please provide the 'require "/local/freeswitch/bin/hook-libs.pl";' file to me for review?
> For PHP or Perl, it's similar for me.
> much more guidline is much helpful.
> Thanks!
> 2014-04-17
> ------------------------------------------------------------------------------------------------------------------------
> sparklezou
> ------------------------------------------------------------------------------------------------------------------------
> *发件人:*Nathan Neulinger <nneul at mst.edu>
> *发送时间:*2014-04-15 20:48
> *主题:*Re: [Freeswitch-users] [Freeswitch-dev] How to check the "fax_result_code" in the script? such as php script?
> *收件人:*"FreeSWITCH Users Help"<freeswitch-users at lists.freeswitch.org>
> *抄送:*
> Can't help you on the PHP side, but I do this with sending a fax with perl based web page. If you're wanting to do it
> inline, I think you'd have to listen for events as you've described...
> ...
>       push( @args, "fax_notify_address='" . $ENV{REMOTE_USER} . "\@mst.edu'" );
>       push( @args, "api_hangup_hook='perl /local/freeswitch/bin/notify-fax-status-hook.pl'" );
> ...
> and then the attached script.
> Key parts:
> our $env;
> our $session;
> my $addr     = $session->getVariable("fax_notify_address");
> my $to       = $session->getVariable("destination_number");
> ...
>       my $fax_status = $session->getVariable("fax_success");
>       my $status_msg = "Sent OK";
>       if ( $fax_status != 1 ) {
>           $status_msg = "Failed";
>       }
>       my $result = $session->getVariable("fax_result_text");
> On 04/15/2014 01:00 AM, sparklezou wrote:
>  > Hi All,
>  > I checked and find two possible solution. But still NOT clear.
>  > 1. Run "fs_cli" in PHP script. But NOT find to correct command to show the channel variables. Nor the data for Mod_spandsp.
>  > https://wiki.freeswitch.org/wiki/Fs_cli#Simple
>  > 2. get info from "Mod event socket". But still NOT very clear how to get the Mod_spandsp event.
>  > https://wiki.freeswitch.org/wiki/Mod_event_socket#api
>  > https://wiki.freeswitch.org/wiki/Event_Socket_Library#events
>  > https://wiki.freeswitch.org/wiki/Event_List#Event-Name
>  > https://wiki.freeswitch.org/wiki/Mod_spandsp
>  > Please share your idea, how to handle such issue?
>  > Hope there is direct way to get the result code, then it will be easy to handle fax step in the script.
>  > Thanks!
>  > 2014-04-15
>  > ------------------------------------------------------------------------------------------------------------------------
>  > sparklezou
>  > ------------------------------------------------------------------------------------------------------------------------
>  > *发件人:*Michael Jerris <mike at jerris.com>
>  > *发送时间:*2014-04-14 20:08
>  > *主题:*Re: [Freeswitch-users] How to check the "fax_result_code" in the script? such as php script?
>  > *收件人:*"FreeSWITCH Users Help"<freeswitch-users at lists.freeswitch.org>
>  > *抄送:*
>  > you could use an api hangup hook, or possibly do it in cdr processing.
>  >
>  > On Apr 10, 2014, at 10:39 PM, sparklezou <sparklezou at 163.com <mailto:sparklezou at 163.com>> wrote:
>  >
>  >> Hi Buddies,
>  >> Reviewed the wiki,https://wiki.freeswitch.org/wiki/Mod_spandsp
>  >> How to check the "fax_result_code" in the php script?
>  >> Also other result info, such as*fax_result_text,*then could provide more detail response info to the client.
>  >> Thanks!
>  >> 2014-03-03
>  >> ------------------------------------------------------------------------------------------------------------------------
>  >> sparklezou
>  >> _________________________________________________________________________
>  >
>  >
>  >
>  > _________________________________________________________________________
>  > Professional FreeSWITCH Consulting Services:
>  > consulting at freeswitch.org
>  > http://www.freeswitchsolutions.com
>  >
>  > 
>  > 
>  >
>  > Official FreeSWITCH Sites
>  > http://www.freeswitch.org
>  > http://wiki.freeswitch.org
>  > http://www.cluecon.com
>  >
>  > FreeSWITCH-dev mailing list
>  > FreeSWITCH-dev at lists.freeswitch.org
>  > http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>  > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
>  > http://www.freeswitch.org
>  >
> --
> ------------------------------------------------------------
> Nathan Neulinger                       nneul at mst.edu
> Missouri S&T Information Technology    (573) 612-1412
> System Administrator - Architect

-- 
------------------------------------------------------------
Nathan Neulinger                       nneul at mst.edu
Missouri S&T Information Technology    (573) 612-1412
System Administrator - Architect



Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-users mailing list