Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Replies are listed 'Best First'.
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

    -- '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 (Abbot) 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.


    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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://779480]
Approved by Corion
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2018-01-22 07:38 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (232 votes). Check out past polls.