LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 07-25-2008, 07:25 AM   #1
G00fy
Member
 
Registered: Jul 2004
Location: Herent, Belgium, Europe, Earth
Distribution: Ubuntu 7.04
Posts: 102

Rep: Reputation: 15
[PHP] unable to execute "hostname" command


Hi,


Recently I moved my programming onto another server. Since that time I am receiving the errors mentioned below (but not everytime).
The weird thing is that I have a 50% to 33% chance of getting the error...

Code:
shell_exec(): Unable to execute "/bin/hostname"
Code:
exec: unable to fork process "hostname 2>&1"
What would be the cause of this issue?
My thinking is that the # of file pointers, or process ids or ... is too low. How and where could I check that? Than I can compare the 2 servers and make the settings equal.

The original server had 2G of Ram, while the new one has 1G of physical RAM. Both have more than enough swap space.


TIA!
Steven
 
Old 07-25-2008, 07:52 AM   #2
leedude
Member
 
Registered: Jan 2007
Location: Scotland
Distribution: Fedora, Debian
Posts: 81

Rep: Reputation: 15
could we see some source code?
 
Old 07-25-2008, 08:06 AM   #3
G00fy
Member
 
Registered: Jul 2004
Location: Herent, Belgium, Europe, Earth
Distribution: Ubuntu 7.04
Posts: 102

Original Poster
Rep: Reputation: 15
sure... The code is fairly simple:

Code:
if ( in_array(trim(strtolower(shell_exec('hostname 2>&1'))), array( 'sqlbe', 'sqlnl' ) )
{
  require_once( dirname(__FILE__) . '/../common.php' );
}
else
{
  require_once( dirname(__FILE__) . '/common.php' );
}
 
Old 07-25-2008, 08:20 AM   #4
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,136

Rep: Reputation: 230Reputation: 230Reputation: 230
I think you can change it like this, to prevent the fork:

PHP Code:
$uname=posix_uname();
$hostname $uname['nodename'];

if ( 
in_array(trim(strtolower($hostname)), array( 'sqlbe''sqlnl' ) )
{
  require_once( 
dirname(__FILE__) . '/../common.php' );
}
else
{
  require_once( 
dirname(__FILE__) . '/common.php' );

 
Old 07-25-2008, 08:27 AM   #5
G00fy
Member
 
Registered: Jul 2004
Location: Herent, Belgium, Europe, Earth
Distribution: Ubuntu 7.04
Posts: 102

Original Poster
Rep: Reputation: 15
Absolutely true. What I do now is read the /etc/hostname file... Which works just fine as well... However do you know what would cause such problem?

The server is a recently installed -and fully updated- Debian server.


Thanks!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to execute "reboot" in cgi script jcaga Fedora 4 05-10-2012 08:45 AM
Standard commands give "-bash: open: command not found" even in "su -" and "su root" mibo12 Linux - General 4 11-11-2007 10:18 PM
Common problems explained: "kernel panic - not syncing", "unable to mount..." sundialsvcs Linux - Newbie 2 03-01-2006 12:17 PM
trying to get new version of mozilla to execute when I give "mozilla" command lynchmob09 Linux - Software 2 12-08-2003 11:13 AM
Ordinary user can execute the "halt" command ederts Linux - Newbie 7 05-24-2001 11:18 AM


All times are GMT -5. The time now is 10:50 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration