User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Perl section within the Software Development category of DaniWeb, a massive community of 456,543 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,319 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Perl advertiser: Programming Forums
Views: 1727 | Replies: 1
Reply
Join Date: Sep 2007
Posts: 4
Reputation: padmaja_3 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
padmaja_3 padmaja_3 is offline Offline
Newbie Poster

Return values from Perl to asterisk

  #1  
Oct 15th, 2007
Hi all,
I'm stuck with how to pass the return value to asterisk. That is, a value has to be passed from perl script to asterisk. The variable returned in Perl has to be passed to asterisk, where if the return value is 1 from perl , i have to do something and if return value is 0, i have to do something else.

I have written code like this.

exten => 9999,23,AGI(insert_into_database.pl|${intime}|${outtime}|${telephone_number}|${date}|${month}|${year}

in Perl Script:
******************

$fullDate = $ARGV[3]."".SARGV[4]."".$ARGV[5];
...........
........(some more code)


if($record == 0 && $rec == 0 && $pri == 0)
{
$stmt = "INSERT into $table_name values($ARGV[0],$ARGV[1],$ARGV[2],$fullDate)";
$fetch = $dbh->prepare($stmt);
$fetch->execute();
}
else
{
print "\nValues cannot be inserted in database\n\n";
}

If that "if" condition satisfies, then it has to return some value, say 0.Otherwise 1. Even if i write return 0, there in "if" condition, how can i get that value to asterisk?

Pls suggest me how to proceed.

Thanks in advance,
Padmaja T N.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2007
Location: North Bay Ontario
Posts: 176
Reputation: trudge is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 20
trudge trudge is offline Offline
Junior Poster

Re: Return values from Perl to asterisk

  #2  
Oct 15th, 2007
Originally Posted by padmaja_3 View Post
Hi all,
I'm stuck with how to pass the return value to asterisk. That is, a value has to be passed from perl script to asterisk. The variable returned in Perl has to be passed to asterisk, where if the return value is 1 from perl , i have to do something and if return value is 0, i have to do something else.

I have written code like this.

exten => 9999,23,AGI(insert_into_database.pl|${intime}|${outtime}|${telephone_number}|${date}|${month}|${year}

in Perl Script:
******************

$fullDate = $ARGV[3]."".SARGV[4]."".$ARGV[5];
...........
........(some more code)


if($record == 0 && $rec == 0 && $pri == 0)
{
$stmt = "INSERT into $table_name values($ARGV[0],$ARGV[1],$ARGV[2],$fullDate)";
$fetch = $dbh->prepare($stmt);
$fetch->execute();
}
else
{
print "\nValues cannot be inserted in database\n\n";
}

If that "if" condition satisfies, then it has to return some value, say 0.Otherwise 1. Even if i write return 0, there in "if" condition, how can i get that value to asterisk?

Pls suggest me how to proceed.

Thanks in advance,
Padmaja T N.


This doesn't look so much like a Perl question as a database question.

You are trying to insert some data into a MySQL table from the looks of your code.
What does $stmt actually contain. I would print it out to see.

You could also use the 'do' function:
$fetch=$dbh->do(qq{INSERT INTO coffees (ID,Price,Name,Section)
						VALUES ($ID,$Price,'$Name','$Section')});

Then check the value of $fetch.
'do' returns a count of the number of rows affected, or 'undef' if an error occurs.
Amer Neely - Web Mechanic
"Others make web sites. We make web sites work!"
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Perl Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Perl Forum

All times are GMT -4. The time now is 5:02 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC