Link to home
Create AccountLog in
Avatar of Borsec
BorsecFlag for Romania

asked on

passing parameters to php script

hello
I want to send some parameters to php script:
The script is called in this way:
<?php
exec("path_to_php.exe sript_to_call.php." > /dev/null 2>&1 &");      
?>
and I want to send one or more parameters to this script.
How can I do this? I'am not sure if this can be made with exec.
any help is welcome.
Avatar of Loganathan Natarajan
Loganathan Natarajan
Flag of India image

try like this,
exec("php -f /var/www/html/www.mysite.com/script.php contact_id=$contact_id company_id=$company_id req_amount=$amount_1 > /dev/null &");
Avatar of Borsec

ASKER

logudotcom: how can I use contact_id in the script?
sorry, you need to have one more output variable and to be retrieved in the script.

ref. https://www.experts-exchange.com/questions/23668573/How-to-grab-variables-from-php-exec-call.html
exec("php -f /var/www/html/http://www.mysite.com/script.php contact_id=$contact_id company_id=$company_id req_amount=$amount_1 > /dev/null &", $output);
print_r($output);

Open in new window

Avatar of Borsec

ASKER

logudotcom
sorry, but this is not working for me
if I make something like this:
exec($phpPath." ".Script.php." > /dev/null  &");      
the script is executed corectly
BUT when I make this
exec($phpPath." ".Script.php." definitionName=$_definitionName > /dev/null  &",$output);
I can not get the value of $output.
I tried to use in Script.php:
-print_r($argv) - not working
-for( $i=1; $i < $argc; ++$i){
         echo $argv[$i];   -  not working

I tried to remove  > /dev/null  & - not working
How can I get the passed value??
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Borsec

ASKER

Helped me to find the problem.
Thanks for the points! ~Ray