1

I have a perl script that executes a php script:

my $phpOutput = `/usr/bin/php /bart/bart.php`;

this works perfectly fine. now i want to add some variables to the url.

my $phpOutput = `/usr/bin/php /bart/bart.php?data=1`;

this fails.

Could not open input file: /bart/bart.php?data=1

any ideas why?

bart2puck
  • 2,432
  • 3
  • 27
  • 53

1 Answers1

5

The ?x=y syntax is for web servers, whereas the CLI expects arguments separated by space after the filename. The way you've written it, PHP thinks that ?data=1 is part of the filename.

You could do

my $phpOutput = `/usr/bin/php /bart/bart.php 1`;

and use the $argv array to retrieve the argument 1 from within the PHP script. Since it's the first argument, it would be $argv[1] (the 0th index is the script name).

Joel Hinz
  • 24,719
  • 6
  • 62
  • 75