Reputation: 1411
It might be kind of a nooby question but ...
How can I possibly run a php command like php /path/to/script.php
on a hosted web-server?
I have no access via SSH or something.
Upvotes: 1
Views: 2911
Reputation: 7618
Have a look at this function, maybe it will help: https://www.php.net/function.exec
By the way why can't you just visit the page you need? In this way the script will run
EDIT:
How to use the exec function:
The exec function allow you tu execute an external program when you do not have access to an ssh consolle. (note that this function can be disabled by the sysadmin )
For example you can use:
$whoami = exec('whoami');
Upvotes: 1
Reputation: 4497
You can check if the program execution commands like exec()
have been disabled on the server side using:
function execEnabled()
{
$arrDisabled = explode(',', ini_get('disable_functions'));
return (!in_array('exec', $arrDisabled));
}
A list of all system execution commands can be found here:
If exec()
, passthru()
etc. have been disabled, there is no way to execute shell commands.
As Christian Ciupponi asked, why would you execute a PHP script using shell command? You could simply include the file to run it if file access to the script is permitted.
Upvotes: 1