GCC compiles, program runs, but only in a CERTAIN directory
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.
GCC compiles, program runs, but only in a CERTAIN directory
Hello! I am having a serious problem when trying to make a CGI-script (which I've done many times before in the past), my program will only run in a CERTAIN folder, and do absolutely nothing in the cgi-scripts folder. For example, here is the output from my terminal:
As you can see, it compiles fine, runs fine in the ~/programs directory, but as soon as I copy it to /var/www/cgi-bin (with permissions on var www and cgi-bin set to 777 for development on my own personal computer [I wouldn't set the server up like this]), the program doesn't run at all.
I am at a complete loss. Please help me.
I am running Fedora Core 3, 64bit version, on a AMD XP 64bit
proccessor
GCC version = g++ (GCC) 3.4.2 20041017 (Red Hat 3.4.2-6.fc3)
The apache server isn't running at the time I tried this test, I disabled it because I thought maybe (just maybe...) it might be causing this problem.
I do not think that I have SELinux running (I remember turning it off sometime in the past), but, honestly, I don't know how to check. I'll try moving the directory and let you know what happens.
No, /var/www/cgi-bin is NOT a separate file system
I've tried a few different things, and... it is strange.
1) /var/www and /var/www/cgi-bin are the ONLY folders that it WONT run in (I haven't tested /var)
2) If MOVE cgi-bin to my home folder, and RECOPY it into ~/cgi-bin, it still wont run.
3) If I MOVE the executable FROM cgi-bin TO ~/, then it wont run.
4) If I REMOVE ~/cgi-test and the RECOPY it from ~/programs TO ~/, then it runs fine.
5) If I REMOVE it from cgi-bin, and recopy it from ~/programs to cgi-bin, then it still wont work.
6) If I delete cgi-bin, and remake it (plus recopy cgi-test to it), then IF CGI-BIN IS IN /var/www
it wont run.
Code:
[th317erd@TheNerd www]$ cd
[th317erd@TheNerd ~]$ ./cgi-test
Content-type: text/html
Hello world![th317erd@TheNerd ~]$ cp ./cgi-test /var/www/cgi-bin/
[th317erd@TheNerd ~]$ cd /var/www/cgi-bin/
[th317erd@TheNerd cgi-bin]$ ls -l
total 12
-rwxrwxr-x 1 th317erd th317erd 6855 Mar 25 23:27 cgi-test
[th317erd@TheNerd cgi-bin]$ ./cgi-test
[th317erd@TheNerd cgi-bin]$ cd ..
[th317erd@TheNerd www]$ ls -l
total 256
(### other entries omitted for clarity)
drwxrwxrwx 2 th317erd th317erd 4096 Mar 25 23:27 cgi-bin
(### other entries omitted for clarity)
[th317erd@TheNerd www]$ rm -fr cgi-bin
[th317erd@TheNerd www]$ mkdir cgi-bin
[th317erd@TheNerd www]$ cp ~/cgi-test /var/www/cgi-bin/
[th317erd@TheNerd www]$ cd cgi-bin/
[th317erd@TheNerd cgi-bin]$ ./cgi-test
[th317erd@TheNerd cgi-bin]$ cd ..
[th317erd@TheNerd www]$ ls -l
total 256
(### other entries omitted for clarity)
drwxrwxr-x 2 th317erd th317erd 4096 Mar 25 23:28 cgi-bin
(### other entries omitted for clarity)
What the heck is going on? I think it is a permissions problem, but where and what?
I don't think you relise, like I said in previous posts, that I have apache disabled. I am simply trying to run the CGI executable from the BASH shell.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.