[SR-Users] Exec - call python script with arguments

Daniel W. Graham dan at cmsinter.net
Wed Dec 13 01:23:35 CET 2017


This ended up being a log file permissions issue. However this worked with root permission only - exec_msg("echo ‘TEST’ > /usr/local/etc/kamailio/test.txt");
This syntax was correct - exec_msg("/usr/local/etc/kamailio/script.py ‘arg1’ ‘arg2’ ‘arg3’");
Thanks for the input.
-dan

From: sr-users [mailto:sr-users-bounces at lists.kamailio.org] On Behalf Of otron2016 at gmail.com
Sent: Monday, December 11, 2017 10:08 AM
To: Kamailio (SER) - Users Mailing List <sr-users at lists.kamailio.org>
Subject: Re: [SR-Users] Exec - call python script with arguments

Probably not the problem though it could be. ...try:

"python /usr/local/etc/kamailio/script.py<http://script.py/> arg1 arg2 arg3"

instead--kamailio doesn't have your shell env and might not pass the script to python even if the script has the #! declaration.

Also, if you pasted the exact command I think there's no space between .py and arg1 (or that could just be my phone).

Hth.


Sent from Samsung Mobile



-------- Original message --------
From: "Daniel W. Graham" <dan at cmsinter.net<mailto:dan at cmsinter.net>>
Date: 12/10/2017 1:04 PM (GMT-06:00)
To: "Kamailio (SER) - Users Mailing List" <sr-users at lists.kamailio.org<mailto:sr-users at lists.kamailio.org>>
Subject: [SR-Users] Exec - call python script with arguments

Trying to call a python script using exec_msg and haven’t had any luck.

The following works:
exec_msg("echo ‘TEST’ > /usr/local/etc/kamailio/test.txt");

The following works from shell:
/usr/local/etc/kamailio/script.py arg1 arg2 arg3

The following does not work from kamailio:
exec_msg("/usr/local/etc/kamailio/script.py arg1 arg2 arg3");

(The arguments are just strings for test purposes)

Kamailio is running as kamailio user


Permissions:
755 script.py

Any idea what could be going wrong?

-dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20171213/15a3a983/attachment.html>


More information about the sr-users mailing list