Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

how to run asterisk command through perl/cgi

by sanku (Beadle)
on Jul 13, 2009 at 07:04 UTC ( #779480=perlquestion: print w/ replies, xml ) Need Help??
sanku has asked for the wisdom of the Perl Monks concerning the following question:

hi monks, The following code is to execute asterisk commands through perl/cgi, but i am getting the following error for this program.
Error: Unable to connect to remote asterisk (does /var/run/asterisk.ctl exist +?) Unable to connect to remote asterisk (does /var/run/asterisk.ctl e +xist?)
And one more thing is if i am running the same program as perl file the asterisk commands are executing without any error.
#!/usr/bin/perl print "Content-type:text/html\n\n"; print `asterisk -rx "extensions reload"`; print `asterisk -rx "sip reload"`;
Can any one help me as soon as possible... Thanks in advance.

Comment on how to run asterisk command through perl/cgi
Select or Download Code
Re: how to run asterisk command through perl/cgi
by targetsmart (Curate) on Jul 13, 2009 at 07:34 UTC
    IMO the program asterisk is unable to work in the CGI environment compared to normal command line environment.

    my suggestion for you is
    print the environment variables inside the cgi program before running the asterisk command and run in both the scenarios to know the difference


    Vivek
    -- 'I' am not the body, 'I' am the 'soul', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.
Re: how to run asterisk command through perl/cgi
by afoken (Parson) on Jul 13, 2009 at 10:57 UTC

    This could also be a permission problem. Remember that CGIs usually run under a different, unprivileged user, typically nobody, wwwrun, or apache. asterisk complains only that it could not connect (to the unix domain socket / pipe /var/run/asterisk.ctl). It does <update>NOT</update> say that /var/run/asterisk.ctl does not exist, but it asks you to check that it exists because missing that pipe / socket seems to be a common error.

    Alexander

    --
    Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)
      I am thinking your asterisk is not running. Try "home/operator# asterisk start", then run your perl script. :-) Iván Carrasco Quiroz.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://779480]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2014-12-26 05:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (165 votes), past polls