Calling perl script and passing variable from php script
Can someone help me please. I am writing php script and thought of combining it with perl because other function can easily processed by perl. I have no problem with calling perl from php.
The following worked fine. PHP Code:
I tried the following: PHP Code:
Is there a way of passing variable to perl? |
Hi
Add a space between the command and the variable. If the variable contains spaces, you also need to use the escapeshellarg function. exec('./perl_script.pl'.' '.EscapeShellArg($variable)); The second parameter to exec will be filled with the commands output by the way. See http://www.php.net/manual/en/function.exec.php |
or,
in the perl script use the -s switch. then you can do: Code:
exec('./perl_script.pl foo=bar'); Code:
#!/usr/bin/perl -s explicit and obvious for future maintainers. |
Thanks bigearsbilly and Guttorm for the solution. I am now smiling :)
It works!! |
I would be very instersted to know how you made it works.
i have got a php script with this (test1.php) PHP Code:
and a perl script with this: Code:
#!/usr/bin/perl -s The idea behind that, is php front end sending the filename to the perl script to process. Does it make sense ? Thanks for any replys |
In this case, why not use $ARGV[0] ?
Code:
#!/usr/bin/perl |
All times are GMT -5. The time now is 12:33 PM. |