[OpenSIPS-Devel] 回复: Devel Digest, Vol 46, Issue 31

Vlad Paiu vladpaiu at opensips.org
Thu Apr 19 11:29:39 CEST 2012


Hi,

You can run your script with an absolute path, so you can put the 
external script wherever you would like.
So you should do something like
     exec_avp("/usr/local/sbin/my_script.py $si", "$avp(should_route)");
     if ($avp(should_route) == "0") {
         send_reply("403","Not relaying");
         exit;
     }
     # continue with regular routing

The $ct in your example, or $si in mine, is passed as an argument to 
your script, so you can fetch it as a regular argument, like sys.argv[1] 
in python.
The result of the script will get returned in $avp(should_route), in my 
example.


Regards,

Vlad Paiu
OpenSIPS Developer
http://www.opensips-solutions.com


On 04/19/2012 12:22 PM, GTS2010 wrote:
> Hi Paiu:
>  First, thank you very much for your help. Today I have read the web 
> you give to me ,and I have some more questions about how to use the 
> exec_avp() fuction , in the web I saw a simple ex:exec_avp("print- 
> contact.sh"$ct""). The questions are where should I put my own 
> script in ? And how to read the $ct in my own script (ex: python)?
> Hoping for your help!
> Thanks & Regards,
> Li Peng beijing China
> 2012-04-19
> 2012-04-19
> ------------------------------------------------------------------------
> GTS2010
> ------------------------------------------------------------------------
> *发件人:*devel-request
> *发送时间:*2012-04-18 23:26
> *主题:*Devel Digest, Vol 46, Issue 31
> *收件人:*"devel"<devel at lists.opensips.org>
> *抄送:*
> Send Devel mailing list submissions to
>     devel at lists.opensips.org
> To subscribe or unsubscribe via the World Wide Web, visit
>     http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
> or, via email, send a message with subject or body 'help' to
>     devel-request at lists.opensips.org
> You can reach the person managing the list at
>     devel-owner at lists.opensips.org
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Devel digest..."
> Today's Topics:
>    1. Re: question (Vlad Paiu)
>    2. (no subject) (Guan Xsun)
>    3. opensips error (Guan Xsun)
> ----------------------------------------------------------------------
> Message: 1
> Date: Wed, 18 Apr 2012 14:41:01 +0300
> From: Vlad Paiu <vladpaiu at opensips.org>
> Subject: Re: [OpenSIPS-Devel] question
> To: devel at lists.opensips.org
> Message-ID: <4F8EA84D.5010506 at opensips.org>
> Content-Type: text/plain; charset="utf-8"; Format="flowed"
> Hello,
> There is no need to develop an extra module for this.
> You can use the exec_avp() function from the exec module ( see #1) and
> call an external script ( bash, python, etc ) that runs your logic, and
> returns the result back to OpenSIPS. Based on the external script
> results, in the OpenSIPS script you can drop or further relay the message. 
>
> 1. http://www.opensips.org/html/docs/modules/devel/exec#id250135
> Regards
> Vlad Paiu
> OpenSIPS Developer
> http://www.opensips-solutions.com
> On 04/18/2012 04:15 AM, GTS2010 wrote:
> > 2012-04-18
> >
> > Hi:
> >
> >    I am a college student from China. I have just started working on opensips. Now I have some questions about it, and I hope you could help me out. 
>
> >
> >    Our project want to add some additional functions on the sip server. The primary is when the server received an invite message from a sip phone, amd the server should get the src-ip and the des-ip of the session. Then send the src-ip and the dst-ip to another computer, in which we run a application that have the informations about the resource of the network (By the way,the server and the sip phones are all in an LAN). Then the application will tell the server whether it should allow this session. In another word, we want to add a judgement in the sip session. 
>
> >
> >     My question is whether the opensips could do that for me? Should I add an additional module in the opensips? Or add some funcitions in some modules whick the opensips already have? How to? 
>
> >
> > Thank you very much for your help!
> >
> > Hoping for your advance.
> >
> > Thanks & Regards,
> >
> > Li Peng Beijing China
> >
> > 2012-04-18
> >
> > ------------------------------------------------------------------------ 
>
> > GTS2010
> >
> >
> > _______________________________________________
> > Devel mailing list
> > Devel at lists.opensips.org
> > http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://lists.opensips.org/pipermail/devel/attachments/20120418/f93aad98/attachment-0001.htm> 
>
> ------------------------------
> Message: 2
> Date: Wed, 18 Apr 2012 23:22:40 +0800
> From: Guan Xsun <guanxiansun at gmail.com>
> Subject: [OpenSIPS-Devel] (no subject)
> To: devel at lists.opensips.org
> Message-ID:
> <CAHBWywC9GpzTueDC9_4SLCxBH-om+KS-S7QxLAwbRFbXNyyWjw at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> HI,all,
>    I enter an error when use opensips.
>    The message  log is listed:
>     Apr 18 08:17:36 localhost opensips: ERROR:core:sr_load_module: 1 could 
>
> not open module </usr/local/lib/opensips/modules/db_mysql.so>:
> /usr/local/mysql/lib/libmysqlclient.so.15: cannot restore segment prot
> after reloc: Permission denied
> Apr 18 08:17:36 localhost opensips: CRITICAL:core:yyerror: 2parse error in 
>
> config file, line 71, column 13-14: failed to load module
> Apr 18 08:17:36 localhost opensips: CRITICAL:core:yyerror: 2parse error in 
>
> config file, line 192, column 1-6: syntax error
> Apr 18 08:17:36 localhost opensips: CRITICAL:core:yyerror: 2parse error in 
>
> config file, line 192, column 1-6: Invalid arguments
> Apr 18 08:17:36 localhost opensips: ERROR:core:main: bad config file (3
> errors)
>   And the opesips.cfg is attached.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://lists.opensips.org/pipermail/devel/attachments/20120418/1a123d1a/attachment-0001.htm> 
>
> ------------------------------
> Message: 3
> Date: Wed, 18 Apr 2012 23:25:20 +0800
> From: Guan Xsun <guanxiansun at gmail.com>
> Subject: [OpenSIPS-Devel] opensips error
> To: devel at lists.opensips.org
> Message-ID:
> <CAHBWywCDDe3=V-Se55O5hRbf_vfnAYGrGdWSKYWh-WHOLYQdoA at mail.gmail.com>
> Content-Type: text/plain; charset="iso-8859-1"
> HI,all,
>    I enter an error when use opensips.
>    The message  log is listed:
>     Apr 18 08:17:36 localhost opensips: ERROR:core:sr_load_module: 1 could 
>
> not open module </usr/local/lib/opensips/modules/db_mysql.so>:
> /usr/local/mysql/lib/libmysqlclient.so.15: cannot restore segment prot
> after reloc: Permission denied
> Apr 18 08:17:36 localhost opensips: CRITICAL:core:yyerror: 2parse error in 
>
> config file, line 71, column 13-14: failed to load module
> Apr 18 08:17:36 localhost opensips: CRITICAL:core:yyerror: 2parse error in 
>
> config file, line 192, column 1-6: syntax error
> Apr 18 08:17:36 localhost opensips: CRITICAL:core:yyerror: 2parse error in 
>
> config file, line 192, column 1-6: Invalid arguments
> Apr 18 08:17:36 localhost opensips: ERROR:core:main: bad config file (3
> errors)
>   And the opesips.cfg is attached.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://lists.opensips.org/pipermail/devel/attachments/20120418/a80dddb6/attachment.htm> 
>
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: opensips.cfg
> Type: application/octet-stream
> Size: 10838 bytes
> Desc: not available
> URL: 
> <http://lists.opensips.org/pipermail/devel/attachments/20120418/a80dddb6/attachment.obj> 
>
> ------------------------------
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
> End of Devel Digest, Vol 46, Issue 31
> *************************************
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20120419/351f3d09/attachment.htm>


More information about the Devel mailing list