To pass an argument with AGI script

Hello,

I know it is possible to pass arguments to a AGI script with a

Agi(myscript.php|arg1)

for a php script for example.

But, where does appear the argument once you are in the php script ? You should have it from STDIN, like other agi variables, shouldn’t you ?

However, the variable I pass doesn’t appear in the standard input :open_mouth:

And because my “GET VARIABLE” doesn’t work (see a previous post), I am forced to write my value in a file, then parse it in my php script. :imp: But that’s ugly :imp: !!

Thank you for helping me be back in beauty…

:smile:

I grab the GetAGIVars(&$agivar) function on an example (i don’t remeber where)
We have 30 differents pone numbers (support, commercial, key accounts, direct lines ,…) and we use this script to rewrite the cid with the name of the line and, if know in our database, the id and the name of the customer (IE “KEY [007 James Bond]”, SUP [000 John DOE])

Hope it helps.

#!/usr/bin/php -q

<?php ob_implicit_flush(true); set_time_limit(6); $stdin = fopen('php://stdin', 'r'); $stdout = fopen('php://stdout', 'w'); $stdlog = fopen('/var/log/asterisk/my_agi.log', 'w'); //------------------------------------------------------------ //------------------------------------------------------------ Function Verbose($line){ echo "VERBOSE \"{$line}\"\n"; }; //------------------------------------------------------------ //------------------------------------------------------------ Function GetAGIVars(&$agivar){ global $stdin; while (!feof($stdin)) { $temp = fgets($stdin); $temp = str_replace("\n","",$temp); $s = explode(":",$temp); $agivar[$s[0]] = trim($s[1]); if (($temp == "") || ($temp == "\n")) { break; }; }; }; //------------------------------------------------------------ //------------------------------------------------------------ Function GetClient($Number,&$Client){ Some code to get the client number and his name from from our interna database }; //------------------------------------------------------------ // MAIN MAIN MAIN Verbose ('START -------------------------'); GetAgiVars($_AGI); if ($argv[1]!='') { $Line = $argv[1]; } else { $Line = 'Ligne '.$_AGI['agi_dnid']; }; GetClient($_AGI['agi_callerid'],$Client); echo "SET CALLERID \"{$Line} ".$Client."\" \n"; Verbose('STOP --------------------------'); fclose($stdin); fclose($stdout); fclose($stdlog); exit; ?>