3

I have a Perl script which inserts values in to a Mysql DB. Within the same script, I check a condition, and if successful, go to the asterisk CLI and run the originate command. When I run it in the terminal it's working properly. When I set it as a crontab, it will update the DB but the originate command is not working. I am new to Perl, please help me to solve this. Thanks in advance.

Perl script:

if($temperature > 85){
    print `asterisk -rx "originate Dongle/dongle0/0123456789 extension 400\@out"`;
}

Crontab:

*/1 * * * *   /home/test/bin/insert_mysql.pl
Craig Treptow
  • 834
  • 7
  • 19

1 Answers1

6

Cron have different environment: he dont have PATH environment variable, so you must always use full path to commands; And, current directory is generally undefined, so when opening files must be careful; Also, it does not have locale settings but i think its not your case.

So you must give full path to asterisk and to file Dongle/dongle0/0123456789 (if it is file)

Galimov Albert
  • 7,269
  • 1
  • 24
  • 50