简体   繁体   中英

Run php command on hosted server

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.

Have a look at this function, maybe it will help: http://it1.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');

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:

http://us.php.net/exec

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM