ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
This did work as far as I came up with an executable but it ran and didn't print anything out at all and I just returned to the prompt. Perhaps it went to some log somewhere?
It did not work for Mac OS X replacing -f elf64 with -f macho64 though
I did not try to add any extension in the linker command but in theory, the server does not need one. "document root" and "cgi-bin" directories have been left as per original default Debian 7 (no need for added "exec .extension" or "alias .." since whatever is in that directory is considered by Apache2 to be cgi executable)
This code does not call the server and also work in my case
but the funny thing is that, calling the server through html submit, itdoes not work in C either even though gcc has no complaint about the source code, doing the same thing in "YABASIC" with two "print" statements in the code (one to screen and the other to file) does not print correctly to the screen (possibly not at all, I cannot remember) altough printing to file shows the correct output (6 'variable name=value' blocks), not code. So it apears that the garbage printed is not code but the correct output (always proportional to the string used) that for some reason Apache2 cannot render correctly. Since the browser is UTF-8 by default which YASM does not understand (although the data is temporarily ASCII only), perhaps, not printing to screen in YABASIC had to be expected so I did not worry too much about that.
I have used verbatim a more involved example from the NCSA (32bit) and it does not work either - same result.
I did not try to add any extension in the linker command but in theory, the server does not need one. "document root" and "cgi-bin" directories have been left as per original default Debian 7 (no need for added "exec .extension" or "alias .." since whatever is in that directory is considered by Apache2 to be cgi executable)
I'm sorry, but that is not correct. The server does need an extension which matches one of the values in AddHandler in the httpd.conf file.
Without a matching extension, apache will not execute the script/program, but will just send the contents of the file, which in your case, is a binary file.
Please add a .cgi extension to your compiled file and try again. I don't believe it needs to be re-compiled with the extension, the file just has to have that name for apache to execute it instead of delivering it.
I believe if it is in a designated cgi-bin directory the web server should try to execute the file and if that fails for some reason (anything from not being able to execute it at all to returning no header or a bad header) it should just give a server error. It shouldn't send the contents of the file, which means wherever the file was, it wasn't in a properly declared cgi-bin directory.
I believe if it is in a designated cgi-bin directory the web server should try to execute the file and if that fails for some reason (anything from not being able to execute it at all to returning no header or a bad header) it should just give a server error. It shouldn't send the contents of the file, which means wherever the file was, it wasn't in a properly declared cgi-bin directory.
I stand corrected. It appears I've been very lazy and have just been applying the
Code:
Option ExecCGI
directive to directories containing executable scripts rather than creating ScriptAlias for them. When doing that, the
Code:
AddHandler cgi-script .cgi .pl
directive is also required.
When a ScriptAlias directive is defined for a folder, then neither of the other directives are required.
I believe I'll do some tweaking of the config file over the next couple of days. Thank you, Laserbeak and NevemTeve
rblampain, what I've been saying will work, it's just not the only way, and probably not the best way. Please confirm that your cgi-bin does have a ScriptAlias defined for it. Something like:
Code:
ScriptAlias /cgi-bin/ /path/to/the/cgi-bin/
...and I would not expect that to be provided by default,because the realname directory needs to be specified. There may be a default example commented out:
Code:
# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname directory are treated as applications and
# run by the server when requested rather than as documents sent to the client.
# The same rules about trailing "/" apply to ScriptAlias directives as to
# Alias.
#
#ScriptAlias /cgi-bin/ "/var/www/cgi-bin"
#
# "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
(which I copied from my current httpd.conf -- which is why I need to use the other two directives
I cannot understand what the problem was. Initially having "charset=urf-8" (maybe not the exact spelling) in the header seemed to make it worse, so I took it out on the assumption that I only had ascci in the testing files. In my last test, I put that back and it works and I have no idea what the difference is. There was no need to alter any configuration, as explained in my previous post.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.