0

I want to execute a CGI on my server, but I have this issue:

run-detectors: unable to find an interpreter for /media/FTP/outils/cgi-bin/monitorCGI.cgi, >refererer: http://outils.mynd/backburner.
Premature end of scripts header: monitorCGI.cgi, referer: >http://outils.mynd/backburner.

My apache2.conf looks like so:

<location /media/FTP/racine/cgi-bin/>
Options +ExecCGI 
AddHandler cgi-script .cgi 
</Location>

My Vhost looks like so:

>VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName SERV-FTP
    DocumentRoot /media/FTP

    Directory /media/FTP/racine/cgi-bin>
        Options +Indexes FollowSymLinks MultiViews +ExecCGI
        AddHandler cgi-script cgi
        Order allow,deny
        allow from all
    /Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Should I link wine to execute this CGI ?

Mark Stosberg
  • 3,771
  • 23
  • 27
Hihui
  • 1
  • 3
  • 1
    What kind of cgi script is it? A perl script? – etagenklo Aug 08 '13 at 09:27
  • 1
    Hi ! don't know what is it really & my reseller can't give me an answer about that. He said me i need wine. So i guess it's an exe ... ? – Hihui Aug 08 '13 at 09:36
  • If it is an actual script and not some unsupported binary executable then "unable to find an interpreter" probably means the interpretor path in the [shebang](http://en.wikipedia.org/wiki/Shebang_(Unix)) is wrong - check the first line of the script and make sure the intepreter is being called with the correct path. Also execute the script manually and see if you get the same error. Finally the "file" command may be of use e.g. "file /media/FTP/outils/cgi-bin/monitorCGI.cgi" if you have shell access. – Friedrich 'Fred' Clausen Aug 08 '13 at 11:16
  • shebang ? I can't see the first line cause it's a compiled CGI (or i don't know how i can read the first line ...) If i execute "wine monitorCGI.cgi" i have an other error "ERROR login procedure could not be completed". It's normal cause i didn't use the .auth file. – Hihui Aug 08 '13 at 11:22
  • 1
    OK, it looks like a windows executable if running it in Wine makes it execute enough to give an actual error message. You could 1) Look for a better monitoring tool that can run natively in your hosting environment or 2) Write a wrapper script that calls wine with your binary, then call that wrapper script as a CGI. Also see [this question](http://stackoverflow.com/questions/2338111/is-there-a-way-to-execute-a-exe-cgi-application-on-linux-apache) for a similar situation. – Friedrich 'Fred' Clausen Aug 08 '13 at 11:29
  • a wrapper like this ? test.php contains ? – Hihui Aug 08 '13 at 11:38
  • Error.log Application tried to create a window, but no driver could be loaded.Make sure that your X server is running and that $DISPLAY is set correctly. err:systray:initialize_systrayCould not create tray window [error] [client 192.168.0.235] File does not exist: /media/FTP/outils/favicon.ico Note that '(null)/.local/share' is not in the search path set by the XDG_DATA_HOME and XDG_DATA_DIRS environment variables,so applications may not be able to find it until you set them. The directories currently searched are: - /var/www/.local/share - /usr/local/share/ - /usr/share/ – Hihui Aug 08 '13 at 11:41
  • Try and use the "wineconsole" command instead. But if it is a GUI (not command line/console) windows app then you're out of luck. Also see [this wine help page](http://www.winehq.org/docs/wineusr-guide/cui-programs). – Friedrich 'Fred' Clausen Aug 08 '13 at 11:45
  • Wineconsole don't help me. – Hihui Aug 08 '13 at 11:57
  • Wineconsole don't help me. monitorCGI can be executed on a windows machine. I'm sure i just need to force wine to execute this CGI, or force apache to execute correctly this CGI... – Hihui Aug 08 '13 at 12:07
  • My reseller said me monitorCGI is able to run on a linux distrib .. but don't tell me how ... :( – Hihui Aug 08 '13 at 12:10
  • Then you should look for a different reseller (or a different script). – etagenklo Aug 08 '13 at 13:10
  • He said, i just configure apache to execute monitorCGI.cgi ... if u have an idea how configure it ... – Hihui Aug 08 '13 at 13:27

1 Answers1

0

The Apache webserver is unable to run the monitorCGI.cgi script because it is unable to find an interpreter to use.

This means that it does not recognise monitorCGI.cgi as a compiled binary, and so is treating it as a script, and therefore wants the first line to be #! /path/to/interpreter for some interpreter.

Since you claim the script is a compiled binary, but Apache does not recognise it as such, it is likely compiled for the wrong architecture.

Try the command file monitorCGI.cgi to see what type of file your OS claims it to be. Possibly it is compiled for 64bit when you're running a 32bit system, or it is a Windows executable when you're running a Linux server. In any case, you need to find a compatible binary for it to work. Try running the script directly form the command line, to verify that it can execute, before running via Apache.

Steve Shipway
  • 742
  • 5
  • 17
  • file monitorCGI.cgi : PE32 executable (console) Intel 80386, for MS Windows. – Hihui Aug 09 '13 at 07:02
  • Under windows, a PE32 executable is a binary file, so MUST have a .exe extension, otherwise Apache will use the cgi-script handler, thinks it is a script and looks for an interpreter. Rename monitorCGI.cgi to be monitorCGI.exe and it should work (though you'll likely need to change whatever it was that linked to it) – Steve Shipway Oct 15 '13 at 03:41
  • I'm using Debian :s – Hihui Oct 16 '13 at 12:28