<?php
$out = array();
$execute='./test.py';
$name="test";
exec("$execute $name",$out);
foreach ($out as $value) {
    echo "$value<br />\n";
}
?>

when I executing above code in local server its working..

But in hosted server, exec () function doesn't take the parameter variable '$name'.

why?

Recommended Answers

All 8 Replies

There are a lot of shared hosting providers that block the use of exec() as it can be a possible security risk when using shared hosting. You should check with your hosting provider to make sure that this command is available to use on your hosting plan.

Two others commonly blocked are:
system()
shell_exec()

There are a lot of shared hosting providers that block the use of exec() as it can be a possible security risk when using shared hosting. You should check with your hosting provider to make sure that this command is available to use on your hosting plan.

Two others commonly blocked are:
system()
shell_exec()

In my hosted server exec() function is working but it cannot takes the parameter '$name'

What type of error does PHP output when the code is run?

What type of error does PHP output when the code is run?

There is no error ,parameter value is not getting in the 'test.py' page

so no output.

Just out of curiosity, what happens when you replace your exec() command with this one?

exec('./test.py test',$out);

Just out of curiosity, what happens when you replace your exec() command with this one?

exec('./test.py test',$out);

Same error

Are you able to SSH into the server and run the script manually? Making sure that you can execute Python scripts on your server?

Are you able to SSH into the server and run the script manually? Making sure that you can execute Python scripts on your server?

Python script is correctly working...
Its the problem with exec() function

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.