Monthly Archives: August 2012

Fixing the “Permission denied” error on /var/lib/asterisk/agi-bin/dialparties.agi

A client calls us earlier  complaining that their  incoming calls are not going through. The call just drops  in. I’ve tried to trace also their log full the /var/log/asterisk/full confirming the issue.  Upon tracing the log file, I can see that there is entries that says “Permission denied”  during my call attempt.

 


[Aug 23 11:09:52] VERBOSE[32336] pbx.c: -- Executing [s@macro-dial:3] AGI("DAHDI/77-1", "dialparties.agi") in new stack
[Aug 23 11:09:52] VERBOSE[32336] res_agi.c: -- Launched AGI Script /var/lib/asterisk/agi-bin/dialparties.agi
[Aug 23 11:09:52] VERBOSE[32337] app_mixmonitor.c: == Begin MixMonitor Recording DAHDI/77-1
[Aug 23 11:09:52] VERBOSE[32336] res_agi.c: dialparties.agi: Failed to execute '/var/lib/asterisk/agi-bin/dialparties.agi': Permission denied
[Aug 23 11:09:52] VERBOSE[32336] pbx.c: -- Executing [s@macro-dial:4] NoOp("DAHDI/77-1", "Returned from dialparties with no extensions to call and DIALSTATUS: ") in new stack
[Aug 23 11:09:52] VERBOSE[32336] pbx.c: -- Executing [s@macro-exten-vm:10] GotoIf("DAHDI/77-1", "0?exit,return") in new stack
[

 

The issue though is just fixed by doing the chmod on /var/lib/asterisk/agi-bin/dialparties.agi.

Just do : chmod 777 /var/lib/asterisk/agi-bin/dialparties.agi

Calling again the  dialer server  after that ‘fix’  and my call went through.

 

PHP simple text file writer and reader code

For file writing

<?php
   $filename = "c:\\temp\\mydata.txt";
   $mystring = fopen($filename, "wb");
   $handle = fopen($filename, "wb");
   $newstring = str_replace("oldword", "newword", $mystring);
   $numbytes = fwrite($handle, $newstring);
   fclose($handle);
   print "$numbytes bytes written\n";
?>

For file reading

<?php
$lines = file('YourFile.txt');
foreach ($lines as $line_num => $line)
{
print "<font color=red>Line #{$line_num}</font> : " . $line . "<br />\n";
}
?>