ah-blabla
New Member
- Messages
- 375
- Reaction score
- 7
- Points
- 0
As we all know, the php function exec() isn't allowed on X10Hosting. However since shell scripts are allowed, it isn't particularly hard to get around this. Is this meant to be the case, since it's rather inconvenient to use a roundabout method to get the same result.
Just so that you know, here is how you can use an equivalent of php exec():
Shell script:
(Note to anyone who actually wants to use this -- assuming that the admins don't block this method: make sure you secure it, ideally with both ip check and with password file. That is what I'm currently adding in.)
To run a program in the directory you just need to call the shell script as such:
http://address.of/script.sh?command to run
this runs 'command to run'
To use this in php you can use this function:
The function returns the program output as a string.
(It would actually be possible to write a full replacement of php exec() if one wanted to. If override_function were available it would be enough to use that at the start of the main php file to make all other code work without modifications.)
Just so that you know, here is how you can use an equivalent of php exec():
Shell script:
Code:
#!/bin/bash
echo "Content-type: text/plain"
echo ""
$1
To run a program in the directory you just need to call the shell script as such:
http://address.of/script.sh?command to run
this runs 'command to run'
To use this in php you can use this function:
PHP:
function execute($name) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://adress.to/script.sh?".$name);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return($output);
}
(It would actually be possible to write a full replacement of php exec() if one wanted to. If override_function were available it would be enough to use that at the start of the main php file to make all other code work without modifications.)
Last edited: