Friday, 15 April 2011

How to run a Perl script from a PHP or Perl file

There comes a time in many a complex system when it is useful to call one Perl file from another.  In my case, a Perl script creating a list of IT accounts to be created had to be called from two distinct places - our PHP online application to use IT facilities, and our Perl admissions administrative interface.

For the PHP page, I created a shell script calling the file in a PHP-bin (it is better for security apparently):


For the Perl, because it is already in a passworded area of our site, I just call the file directly:

system("/usr/bin/perl /home/httpd/yourpath/directory/filename.perl");