News & Reviews
More How-To's & Tips More News
More Reviews Device Configuration Tools
No account yet? Create one
Forgot your Username or Password?

Welcome to the Voxilla VoIP Forum.

Voxilla has been a trusted source for accurate, up-to-date information on the IP Communications industry since 2002. A dedicated staff of reporters and engineers produce feature articles and product reviews to keep industry watchers abreast of the people, companies, and trends driving a fast moving market.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.





Closed Thread
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old April 2nd, 2007, 03:25 PM
rtskarthik rtskarthik is offline
Junior Member
 
Join Date: Feb 2007
Posts: 15
rtskarthik is on a distinguished road
Default asterisk c script

HI

I am new to asterisk world. My c script is not executing.
I have done the following stuffss:
1) created a file called cscript.c
#include <stdio.h>
#include <string.h>
main() {
char line[80];
/* use line buffering */
setlinebuf(stdout);
setlinebuf(stderr);
/* read and ignore AGI environment */
while (1) {
fgets(line,80,stdin);
if (strlen(line) <= 1) break;
}
printf("SAY NUMBER 1234567891 \"\"\n");
fgets(line,80,stdin);
fputs(line,stderr);
}
2)compiled it using gcc compiler at the agi-bin directory

3) used the following statement at the extension.conf file
exten => 1234,1,Answer()
exten => 1234,2,AGI(cscript.c)

4)the i dialed using the dial string 1234@incoming

5) The output from asterisk console is
-- Executing AGI("OSS/dsp", "cscript.c") in new stack
-- Launched AGI Script /var/lib/asterisk/agi-bin/cscript.c
-- AGI Script cscript.c completed, returning 0
== Auto fallthrough, channel 'OSS/dsp' status is 'UNKNOWN'
<< Hangup on console >>

But when i tried to run the sample perl file it executed rightly..

What is wrong with the following scenario

Please help me. I have no clues

Regards
Karthik
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #2 (permalink)  
Old April 2nd, 2007, 05:49 PM
dswartz dswartz is offline
Senior Member
 
Join Date: Oct 2005
Posts: 149
dswartz
Default Re: asterisk c script

cscript.c is the C source file. when you compile it, you will get a.out or cscript or some other name. you are trying (it seems) to execute the C source file...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #3 (permalink)  
Old April 3rd, 2007, 06:46 AM
rtskarthik rtskarthik is offline
Junior Member
 
Join Date: Feb 2007
Posts: 15
rtskarthik is on a distinguished road
Default Re: asterisk c script

HI

Thanks for the reply,
I have a file called a.out in the agi-bin directory. I replaced in extension.conf file and tried to run with the following line
exten => 1234,1,Answer()
exten => 1234,2,AGI(a.out)

The script is running.

Regards
Karthik
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #4 (permalink)  
Old April 3rd, 2007, 05:03 PM
dswartz dswartz is offline
Senior Member
 
Join Date: Oct 2005
Posts: 149
dswartz
Default Re: asterisk c script

you should probably rename a.out to something more descriptive.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #5 (permalink)  
Old April 4th, 2007, 06:11 AM
rtskarthik rtskarthik is offline
Junior Member
 
Join Date: Feb 2007
Posts: 15
rtskarthik is on a distinguished road
Default Re: asterisk c script

Hi
I worked out with renaming the file also.

I would like to address one more difficulty when i make outboud call using ITSP account.
The problem is that i couldnot get connected to the other party.

My sip.conf file

[sipprovider-out]
username = my username
secret= mypassword
host= sip provider.com
from domain = sip provider.com
qualify = yes
insecure= very
nat=no
disallow = all
allow = ulaw
allow = alaw
allow = ilbc
allow = g729
context = mycontext

[1234]
username = karthik
secret = passdaword
host = dynamic
disallow = all
allow = ulaw
allow = alaw
allow = ilbc
allow = g729
context = mycontext

My extensions.conf
[mycontext]
exten => _0.,1,Dial(SIP/${EXTEN:1}@sipprovider-out,20,r)
exten => _0.,2,Hangup()

My dial string from my asterisk console
dial 01234654789@mycontext

the output which i got in asterisk console
Executing -----------> Dial(123456789@sipprovider-out)
Called -------------> 123456789

Afterwhich i could hear the ringing sound for about 20 seconds

Then it replied as "no bodypicked up in 20 seconds"

Please help me

Thanks in advance


Regards
Karthik
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old April 4th, 2007, 06:11 AM
  #6 (permalink)  
Old April 4th, 2007, 06:13 AM
rtskarthik rtskarthik is offline
Junior Member
 
Join Date: Feb 2007
Posts: 15
rtskarthik is on a distinguished road
Default Re: asterisk c script

Hi

Please ignore my previous mail.


I would like to address one more difficulty when i make outboud call using ITSP account.
The problem is that i couldnot get connected to the other party.

My sip.conf file

[sipprovider-out]
type =friend
username = my username
secret= mypassword
host= sip provider.com
from domain = sip provider.com
qualify = yes
insecure= very
nat=no
disallow = all
allow = ulaw
allow = alaw
allow = ilbc
allow = g729
context = mycontext

[1234]
type =friend
username = karthik
secret = passdaword
host = dynamic
disallow = all
allow = ulaw
allow = alaw
allow = ilbc
allow = g729
context = mycontext

My extensions.conf
[mycontext]
exten => _0.,1,Dial(SIP/${EXTEN:1}@sipprovider-out,20,r)
exten => _0.,2,Hangup()

My dial string from my asterisk console
dial 01234654789@mycontext

the output which i got in asterisk console
Executing -----------> Dial(123456789@sipprovider-out)
Called -------------> 123456789

Afterwhich i could hear the ringing sound for about 20 seconds

Then it replied as "no bodypicked up in 20 seconds"

Please help me

Thanks in advance


Regards
Karthik
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #7 (permalink)  
Old April 10th, 2007, 05:42 AM
chandave chandave is offline
Senior Member
 
Join Date: Jul 2005
Posts: 362
chandave is an unknown quantity at this point
Send a message via MSN to chandave
Default Re: asterisk c script

Quote:
Originally Posted by rtskarthik View Post
Hi

The problem is that i couldnot get connected to the other party.

My sip.conf file

[sipprovider-out]
type =friend
:
host= sip provider.com
:
nat=no
:
context = mycontext

[1234]
type =friend
:
host = dynamic
:
context = mycontext

My extensions.conf
[mycontext]
exten => _0.,1,Dial(SIP/${EXTEN:1}@sipprovider-out,20,r)
exten => _0.,2,Hangup()

My dial string from my asterisk console
dial 01234654789@mycontext

the output which i got in asterisk console
Executing -----------> Dial(123456789@sipprovider-out)
Called -------------> 123456789

Afterwhich i could hear the ringing sound for about 20 seconds

Then it replied as "no bodypicked up in 20 seconds"
Because you have the "Asterisk generate the ringing tone" immediately instead of waiting for call progress status from your VoIP Service Provider (VSP), it is difficult to determine if your VSP even got the SIP INVITE properly from you and is processing it.

I would suggest you temporarily remove the "r" at the end of the Dial() command. From this:
exten => _0.,1,Dial(SIP/${EXTEN:1}@sipprovider-out,20,r)
to this:
exten => _0.,1,Dial(SIP/${EXTEN:1}@sipprovider-out,20)
Then, at Asterisk Command Line Interface (CLI), issue the commands:
set verbose 5
sip debug peer sip provider.com
where sip provider.com is the sip provider you specified in your "host=..." line of "sipprovider-out".

What you should see when you dialout will be:
  • SIP "INVITE" from your Asterisk to your VSP
  • SIP "180 Trying" response from your VSP
  • SIP "200 OK" response from your VSP if the call is picked up by the remote end
  • SIP "BYE" issued from your Asterisk if you hang up the call OR a SIP BYE from the VSP if the other end hangs up the call.
  • SIP "180 Trying" being sent as a reply to the SIP BYE
  • SIP "200 OK" when the call is finally broken down
You can ignore any SIP OPTIONS message you might see. If you never receive the SIP "180 Trying" sent back from your VSP, then that means they cannot send a reply back to you. This might be a Network Address Translation (NAT) problem if your Asterisk box is behind a consumer home router.

I would suggest you open a new thread instead of continuing this one. In the new thread, you need to also include information about your network configuration (behind a home router or not, type of router, which ports are forwarded, what your sip.conf has configured for localnet/externip/externhost, etc).

Additionally, a copy of the SIP dialog between your Asterisk box and your VSP would be very useful as well.

See ya...

d.c.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #8 (permalink)  
Old April 11th, 2007, 04:21 PM
rtskarthik rtskarthik is offline
Junior Member
 
Join Date: Feb 2007
Posts: 15
rtskarthik is on a distinguished road
Default Re: asterisk c script

Hi

Thanks I got it to work from asterisk console. but the for the same i could not get it to work from extension
I have posted my query in new thread

Regards
Karthik
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #9 (permalink)  
Old April 17th, 2007, 02:29 PM
rtskarthik rtskarthik is offline
Junior Member
 
Join Date: Feb 2007
Posts: 15
rtskarthik is on a distinguished road
Default Re: asterisk c script

Hi
Is the way passing the destination calling number to the c script?
exten => _1.,1,AGI(cscript|${EXTEN}).

How should the arguments be retrieved?

I could not retrieve the arguments in the c script when i use the command line arguments

Please provide me some samples. I could not find any examples through googling

Regards
Karthik
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #10 (permalink)  
Old April 18th, 2007, 05:06 AM
chandave chandave is offline
Senior Member
 
Join Date: Jul 2005
Posts: 362
chandave is an unknown quantity at this point
Send a message via MSN to chandave
Default Re: asterisk c script

http://www.voip-info.org/wiki/view/Asterisk+AGI

http://www.bitflipper.ca/Documentation/agi.html

I assume you know how to access command line parameters from within a C program. If not, then I would suggest you grab a copy of the Kernighan and Ritchie book The C Programming Language or a C Tutorial.

See ya...

d.c.

Last edited by chandave : April 18th, 2007 at 05:07 AM. Reason: Fighting with the editor about displaying URLs again
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Old April 18th, 2007, 05:06 AM
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:



Similar Threads for: asterisk c script
Thread Thread Starter Forum Replies Last Post
Need Offhook script for CIT200 greenman Linksys (Sipura) VoIP Support Forum 0 January 19th, 2007 01:25 PM
Help with AA script on SPA9000 JoWeaver Linksys SPA9000/SPA400 Support Forum 0 June 28th, 2006 03:32 PM
AGI and a bash script SpaceBass Asterisk Support Forum 2 May 13th, 2006 04:31 PM
asterisk script help hi_reach Asterisk Support Forum 1 April 7th, 2006 04:32 PM
dial tone script tassos Linksys (Sipura) VoIP Support Forum 1 December 14th, 2005 10:15 PM



All times are GMT. The time now is 04:17 AM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd. SEO by vBSEO 3.0.0 ©2007, Crawlability, Inc. Logos and trademarks are the property of Voxilla or their respective owner. All other content © 2003-2007 by Voxilla, Inc.