Question

i am using shell_exec to get whois details of a domain. Everything is working fine on localhost but when i am uploading the script on server, it is creating problems. On server, the shell_exec is working partially.

echo "shell_exec('whoami')";

gives me an output.

mac

but when i am using

echo "shell_exec('whois example.com')";

I am getting a blank page

Should i consider using a hosting account with root privilege? If yes then how to deal with security issues?

P.S- i dont know if something like this even exists but i've tested it on localhost and it is running fine on MAMP.

Thanks in advance.

Was it helpful?

Solution

If you do decide to host this script with root privileges, then you should (and I'm sorry) be locked up in a padded cell. That's just mad! You don't need root privileges to run a simple whois command. That's insane!
Hosting as root is about as safe as a nursery, ran by catholic priests, serial killers and crack addicts, who haven't had a fix in three days. Things are going to happen... You can only speculate as to when and how bad it's going to end.

Check using whoami what user is running the script, then check what it's PATH looks like, compare that to where whois actually is, if at all present. If it's not installed, ask your admin to set it up, and give you the rights to use it. If it's installed, try shel_exec('/path/to/bin/whois example.com');
Read up on user rights, and environment variables, (and how to load/manipulate them from a PHP script)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top