Jump to content

Recommended Posts

my php page should return the data for and IP address after I shell_exec(); a variable containing the command to be sent to the system.

 

what is getting returned is

sh: line 1: whois: command not found

 

could this have something to do with access issues on my godaddy hosting account? below is the function that is supposed to echo the data.

 

$whois_ip_server = 'whois.arin.net';
$arin_ip = whois_ip($whois_ip_server, '-1', 'TRUE');


function whois_ip($whois_ip_server, $whois_ip_port, $do_echo)
{
if (eregi("^[a-z0-9\:\.\-]+$", $whois_ip_server))
{
	$host_ip = '62.219.133.209';

	// The whois server "whois.arin.net" requires a "+" flag to get all the details
	if ($whois_ip_server == 'whois.arin.net') {
		$whois_ip_server .= ' +'; }

	// Set a variable containing the command to be sent to the system
	$command = "whois -h $whois_ip_server $host_ip";

	// If we passed a specific port to this function to connect to, add the necessary info to the command
	if ($whois_ip_port > 0) {
		$command .= " -p $whois_ip_port"; }

	// Send the whois command to the system
	//   Normally, the shell_exec function does not report STDERR messages.  The "2>&1" option tells the system
	//   to pipe STDERR to STDOUT so if there is an error, we can see it.
	$fp = shell_exec("$command 2>&1");

	// If the $do_echo variable is set to "TRUE", send the results to the parse_output() function...
	if ($do_echo == 'TRUE')
	{
		$output = '<b>Whois (IP) Results:</b><blockquote>';
		$output .= nl2br(htmlentities(trim($fp)));
		$output .= '</blockquote>';

		echo $output;
	}
	// ...otherwise, return the results in a variable (i.e. for the ip_to_country() function)
	else {
		return $fp; }
}
else
{
	echo '<b>Whois (IP) Results:</b><blockquote>';
	echo 'Invalid character(s) in the Whois (IP) Server field.';
	echo '</blockquote>';
}
}

Link to comment
https://forums.phpfreaks.com/topic/150090-shell_exec-issues/
Share on other sites

More than likely, Godaddy has probably added something like this in your php.ini:

 

disable_functions = "exec,system,passthru,readfile,shell_exec,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,dl,popen,show_source"

 

If you can alter this, then you might be able to do what you want to do.

Link to comment
https://forums.phpfreaks.com/topic/150090-shell_exec-issues/#findComment-788238
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.