I've downloaded the command-line program "Whitaker's Words" which was available for Linux as well as Windows etc.

There is a main program named words. I tried to execute it on my Ubuntu (11.10) machine on command line and it worked:


When I tested it on my Linux webserver (Linux 2.6.37-he-xeon-64gb+1 i686), it worked as well.

Then I decided to apply some changes to the source code and to recompile it. For that, I used the following commands (the latter four are supporting programs):

gnatmake -O3 words -bargs -static
gnatmake makedict -bargs -static
gnatmake makestem -bargs -static
gnatmake makeefil -bargs -static
gnatmake makeinfl -bargs -static

The resulting program worked properly on my Ubuntu machine again, as I could see the correct output in the terminal.

But when I tried to execute it on my webserver using PHP's shell_exec() or passthru(), there was simply no output! According to ldd, the program is statically linked so it should really work, shouldn't it?

I've been testing and debugging for weeks now and I can't find any reason why this is so. Can you help me?

You can get the program here: download link at filedropper.com

(I guess this is no programming question, as my problem is just: How to get that program running on my webserver?)

System I want to compile the program on:

Linux ubuntu 3.0.0-12-generic #20-Ubuntu x86 GNU/Linux

This is the newest Wubi (32-bit) release of Ubuntu.

ldd --version outputs ldd (Ubuntu EGLIBC 2.13-20ubuntu5) 2.13

System I want to run the compiled program on (webserver):

Linux 2.6.37-he-xeon-64gb+1 i686 GNU/Linux

ldd --version outputs ldd (GNU libc) 2.7


Errors on the server side can be excluded as everything works fine if I just replace my own Linux program by the pre-compiled one.

Update #1:

I've tried running the program (that works fine under Ubuntu 11.10) in my VirtualBox under Ubuntu 5.10 - and it didn't work, either. Good news, so it's definitely not the server's fault. Ubuntu 5.10 just said: floating point exception. Does this help? Why is there an exception but not under Ubuntu 11.10?

Update #2:

Now compiled with Ubuntu 5.1 using GNAT 3.4. But all hope for nothing - still no output, ldd says statically linked (as I've compiled it that way) and strace gives the same error message. What does it mean? Is there any file missing? Is this the reason why it is not working?

execve("./words", ["./words"], [/* 15 vars */]) = 0
brk(0)                                  = 0x811e000
access("/etc/ld.so.nohwcap", F_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb76f8000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb76f7000
set_thread_area({entry_number:-1 -> 6, base_addr:0xb76f7680, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++
  • Does program execute? Are the environment settings between your shell and shell escape from PHP the same?
    – Karlson
    Apr 4, 2012 at 13:34
  • It seems that the program does not execute on my webserver as I can't see any output in PHP. But on my Ubuntu machine, it does execute. How can I check if these environment settings are the same?
    – caw
    Apr 4, 2012 at 13:53
  • The weird fact is that the pre-compiled version runs on both systems but my self-compiled program does only on the Ubuntu machine, not on the webserver.
    – caw
    Apr 4, 2012 at 23:35
  • Are you unable to login to the box to execute this program on the command line? Perhaps you are forgetting to echo the output of the command (e.g. <? shell_exec('...'); ?> instead of <? echo shell_exec('...'); ?>.)
    – kwarrick
    Apr 8, 2012 at 6:15
  • You don't specify — what flavour of UNIX is your webserver running and on what architecture? If it's not Linux (there are many other UNIXen out there) or isn't of a compatible processor architecture, static linking doesn't help. Also, if the webserver is running an older Linux kernel, you may need to link with an older Glibc, as the newer code might not run on it.
    – ephemient
    Apr 8, 2012 at 7:20

3 Answers 3


When you execute anything as a shell escape from the webserver or any other program the environment settings quite likely don't get applied. For example variables like: PATH, LD_LIBRARY_PATH, etc have their default settings or no settings whatsoever so when you are doing the shell escape you should at least do the following:

  • Call the program by full path: e.g. /usr/local/bin/gnatmake or /usr/local/bin/words
  • get the output of /usr/bin/env to make sure that in the shell escape it has proper settings. Check the same settings in your terminal shell.
  • If you have control of the webserver try to make it execute as your UID to avoid permissions issues.
  • Check which libraries are required for the program if any ldd /usr/local/bin/words


Instead of executing the program directly use the following script:

. /etc/profile

./words 2>&1

and post the output. This will tell you if the program executes and if it crashes.

One more thing to check is whether or not user www-data or whatever is running the ./words is capable of accessing the database that ./words needs if any.

  • Thank you very much! Executing /usr/bin/env resultet in APACHE_PID_FILE=/var/run/apache2.pid APACHE_RUN_USER=www-data MONIT_DATE=... MONIT_HOST=... PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin PDFLIBLICENSEFILE=/etc/pdflib/pdflib_licence _=/usr/bin/env PWD=... APACHE_RUN_GROUP=www-data MONIT_PROCESS_PID=0 MONIT_EVENT=Started MONIT_PROCESS_MEMORY=0 SHLVL=4 MONIT_PROCESS_CPU_PERCENT=0 MONIT_SERVICE=apache2 MONIT_PROCESS_CHILDREN=0 MONIT_DESCRIPTION=failed, cannot open a connection to INET[...] via TCP. Full path did not change anything. ldd see question above.
    – caw
    Apr 4, 2012 at 23:31
  • PWD was /is/htdocs/www/words by the way, if this is important.
    – caw
    Apr 4, 2012 at 23:33
  • @MarcoW. Where is words program?
    – Karlson
    Apr 9, 2012 at 21:14
  • The PHP script is in / and the program words is in /words/. This is the path that PWD returned as well. Of course, I did chdir('words') in PHP to change the directory.
    – caw
    Apr 10, 2012 at 0:24
  • 1
    – Karlson
    Apr 12, 2012 at 21:11

Try running not the program itself but a script running this program and logging it's environment and STDERR output.

You also should have peeked into your WEB server logs.

  • Thank you for these suggestions! In my webserver's log file, there's no entry that belongs to the program. Only the call of the PHP file is mentioned. And in the error log file, there's nothing which belongs to my program as well. When I created a Python script with #!/usr/bin/python print "Hello World\n" import os; os.system("./words"); and called it via PHP, it produced exactly the same results as calling the Linux program directly in PHP.
    – caw
    Apr 8, 2012 at 23:21
  • @MarcoW. So the expected "Hello World" from Python didn't work either? Perhaps your webhost has disabled exec?
    – ephemient
    Apr 9, 2012 at 2:31
  • 1
    Ur script didn't verify os.system runs ok. You need more verbosity to resolve the issue, man.
    – poige
    Apr 9, 2012 at 4:17
  • @ephemient: Sorry, "Hello World" did work. I was just refering to the output of the Linux program. So I had "Hello World" and then no output from the Linux program. @poige: Unfortunately, I don't know any python so I don't know how to check if os.system works correctly. I just thought I had to use Python or some other scripting language different from PHP.
    – caw
    Apr 9, 2012 at 11:13
  • Something like this: codetidy.com/2467
    – poige
    Apr 9, 2012 at 11:28

uh... I am a super-beginner in programming, but... maybe compiling the program in the webserver? Or make a virtual machine with same configuration that you run on webserver, to compile the code there.

Because one is x86, and the other is i686, right?

  • Yes, that would be the easiest solution :D Thanks, in most cases it would work, I'm sure. But on my webserver (shared hosting), GNAT/GCC is not available as it is not needed on webservers in most cases. And I have no possibility to install it. So I have to compile the program elsewhere. Unfortunately.
    – caw
    Apr 11, 2012 at 23:51
  • hmmmm.. if you really can not install gcc into the webserver, maybe best solution is to simulate this: create a virtual machine on your compiler machine with a similar configuration you use on webserver, then compile the code inside virtual machine... just my 2 bits...
    – H_7
    Apr 11, 2012 at 23:54
  • 1
    I am a beginner, but I try hard. =P
    – H_7
    Apr 11, 2012 at 23:56
  • Yes, this is what I've just done. Please see the update in my question above. But it didn't work, either. Because there seems to be a file missing (SIGSEV - segmentation fault?). Is this the reason?
    – caw
    Apr 12, 2012 at 0:01
  • 1
    I have GNAT 3.4 but GCC 4.0 - that's right. I don't know if this causes the problem. Thanks, anyway!
    – caw
    Apr 12, 2012 at 0:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.