Koozali.org: home of the SME Server

Unable to get CGI scripts to run

Offline del

  • *
  • 765
  • +0/-0
Unable to get CGI scripts to run
« on: June 22, 2013, 05:31:10 PM »
Hi All,

I know this has been covered many times but after searching on here and on Google I have finally conceded defeat and realise I need some help :-)
I have tried all the normal things like uploaded again as ASCII, CHMOD to 755 etc. I can get the exact same script to run OK on my web hosting account so I know that everything is OK in the .pl file but I still get the dreaded "Internal Server Error" Do I have to enable anything on my server, I am using the primary i-bay so I guessed that I wouldn't have to but maybe I'm wrong (wouldn't be the first time :-)) Any help is greatly appreciated.

Regards,
Del
If at first you don't succeed, then sky-diving is not for you!
"Life is like a coin. You can spend it anyway you wish, but you can only spend it once." --Author Unknown

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Unable to get CGI scripts to run
« Reply #1 on: June 22, 2013, 06:40:19 PM »
I think cgi scripts need to go into <ibayname>/cgi-bin, and you need to have CgiBin enabled for the ibay:

db accounts show <ibayname>
<ibayname>=ibay
    AllowOverride=All
    CgiBin=enabled
    FollowSymLinks=enabled
    Gid=5006
    Group=admin
    Name=<ibayname>
    PHPBaseDir=/home/e-smith/files/ibays/<ibayname>/:/tmp/
    PasswordSet=no
    PublicAccess=global
    Uid=5006
    UserAccess=wr-group-rd-everyone

Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #2 on: June 22, 2013, 07:13:24 PM »
Hi mmccarn,

I am using the primary i-bay so when I run that command I get this output:
Quote
primary=system

I have tried creating an i-bay called sle and I still get the Internal Server Error when running the cgi script, when I run the command for that i-bay I get this output:
Quote
sle=ibay
    CgiBin=enabled
    Gid=5002
    Group=admin
    Name=sle
    PasswordSet=no
    PublicAccess=global
    Uid=5002
    UserAccess=wr-group-rd-everyone

The only difference I see is in your example is line 4 Gid=5006 is Gid=5002 and line 10 Uid=5006 is Uid=5002
So I'm at a loss with it.

Regards,
Del
If at first you don't succeed, then sky-diving is not for you!
"Life is like a coin. You can spend it anyway you wish, but you can only spend it once." --Author Unknown

Offline mmccarn

  • *
  • 2,653
  • +10/-0
Re: Unable to get CGI scripts to run
« Reply #3 on: June 22, 2013, 08:28:06 PM »
Is there anything interesting in your log files?
/var/log/httpd/access_log (is your script being requested?)
/var/log/httpd/error_log (is your script generating an error within apache?)
/var/log/messages (is your script logging something useful here?)



Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #4 on: June 22, 2013, 08:40:01 PM »
This is what is shown -

Access log

Quote
"POST /cgi-bin/mail_ht.pl HTTP/1.1" 500 543 "http://ddj.homelinux.com/contact.html" "Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20100101 Firefox/21.0"


Error log

Quote
[Sat Jun 22 19:32:58 2013] [error] [client 192.168.0.1] (2)No such file or directory: exec of '/home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl' failed, referer: http://ddj.homelinux.com/contact.html
[Sat Jun 22 19:32:58 2013] [error] [client 192.168.0.1] Premature end of script headers: mail_ht.pl, referer: http://ddj.homelinux.com/contact.html

Nothing in the message log.
If at first you don't succeed, then sky-diving is not for you!
"Life is like a coin. You can spend it anyway you wish, but you can only spend it once." --Author Unknown

Offline janet

  • *****
  • 4,812
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #5 on: June 23, 2013, 01:59:57 AM »
del

Did you put the scripts into the cgi-bin subfolder that is in the ibay (automatically created by smeserver) ?
Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline TerryF

  • grumpy old man
  • *
  • 1,847
  • +6/-0
Re: Unable to get CGI scripts to run
« Reply #6 on: June 23, 2013, 07:27:11 AM »
Maybe I am just barking up a tree however,

When I go to that URL, http://ddj.homelinux.com/contact.html, the "Send Email" button calls the script from http://192.168.0.3/cgi-bin/mail_ht.pl

Maybe change the local ip to the domain address..

When I do that I can see the script, so I suspect permissions etc are also in the game.
« Last Edit: June 23, 2013, 07:29:49 AM by TerryF »
--
qui scribit bis legit

Offline TerryF

  • grumpy old man
  • *
  • 1,847
  • +6/-0
Re: Unable to get CGI scripts to run
« Reply #7 on: June 23, 2013, 07:38:24 AM »
I put a copy of your script in my primary iBay cgi-bin folder with permissions of 0755 and it worked fine.
--
qui scribit bis legit

Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #8 on: June 23, 2013, 10:24:10 AM »
Hi Janet & Terryf,

Janet, yes I have put it in the cgi-bin folder

Terry, I changed that to a local address late last night to try it locally, it was http://ddj.homelinux.com/cgi-bin/mail_ht.pl I've now put that bask in there. One thing how did you get the script? I thought that the cgi-bin was not available to the public :-o

Terry what setup do yuo have? I have my server in server only mode with http forwarded from the router would this make any difference?

Regards,
Del
If at first you don't succeed, then sky-diving is not for you!
"Life is like a coin. You can spend it anyway you wish, but you can only spend it once." --Author Unknown

Offline TerryF

  • grumpy old man
  • *
  • 1,847
  • +6/-0
Re: Unable to get CGI scripts to run
« Reply #9 on: June 23, 2013, 01:17:14 PM »
Terry, I changed that to a local address late last night to try it locally, it was http://ddj.homelinux.com/cgi-bin/mail_ht.pl I've now put that bask in there. One thing how did you get the script? I thought that the cgi-bin was not available to the public :-o

When I access the script using the URL http://ddj.homelinux.com/mail_ht.pl it displays it as a text file, simple save as and I have it.

Quote
Terry what setup do you have? I have my server in server only mode with http forwarded from the router would this make any difference?

First test was on a SME8 VM with all updates, Server Only. Forwarding should not be an issue, make sure of the permissions.

This is where I have now put the script as it is a stand alone SME8 box remote from me, again in server only mode permissions set to 0755, it will be deleted shortly - Test Mail Script

Where is that server, is it at your home/office etc and simply run off your adsl line?
« Last Edit: June 23, 2013, 01:22:27 PM by TerryF »
--
qui scribit bis legit

Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #10 on: June 23, 2013, 05:02:58 PM »
When I access the script using the URL http://ddj.homelinux.com/mail_ht.pl it displays it as a text file, simple save as and I have it.

Ah I see, yes that file was just put there for testing (I wanted to see if I could access it outside of the cgi-bin)


Where is that server, is it at your home/office etc and simply run off your adsl line?

That is correct (at home) in Server Only (Virgin 100mb)

All permissions are 0755.
« Last Edit: June 24, 2013, 12:02:34 AM by del »
If at first you don't succeed, then sky-diving is not for you!
"Life is like a coin. You can spend it anyway you wish, but you can only spend it once." --Author Unknown

Offline TerryF

  • grumpy old man
  • *
  • 1,847
  • +6/-0
Re: Unable to get CGI scripts to run
« Reply #11 on: June 24, 2013, 12:15:21 AM »
If you issue the following at a command prompt without a name

 db accounts show

You will get a list of all accounts, in particular it will list the settings for the primary iBay.

This is the details for the server that I had the script on:

[root@bschclassroom ~]# db accounts show
Primary=ibay
    CgiBin=enabled
    DriveLetter=W
    Group=shared
    Modifiable=no
    Name=Primary i-bay
    PasswordSet=no
    Passwordable=no
    PublicAccess=global
    Removable=no
    UserAccess=wr-admin-rd-group

--
qui scribit bis legit

Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #12 on: June 24, 2013, 12:32:02 AM »
This is what I get after running the command -

Quote
Primary=ibay
    CgiBin=enabled
    Group=shared
    Modifiable=no
    Name=Primary i-bay
    PasswordSet=no
    Passwordable=no
    PublicAccess=global
    Removable=no
    UserAccess=wr-admin-rd-group
« Last Edit: June 24, 2013, 12:46:43 AM by del »
If at first you don't succeed, then sky-diving is not for you!
"Life is like a coin. You can spend it anyway you wish, but you can only spend it once." --Author Unknown

Offline TerryF

  • grumpy old man
  • *
  • 1,847
  • +6/-0
Re: Unable to get CGI scripts to run
« Reply #13 on: June 24, 2013, 01:49:56 AM »
So as long as the permissions are set Ok, there would seem to be no reason why that script would not run.

Got me, it needs a smarter mind than mine to suggest further avenues of investigation.

There has to be something that is preventing the execution..

I tried it on another remote system in a iBay other than the primary, no probs as long as the permissions were 0755, what are you using to upload the file with, I am using WinSCP
--
qui scribit bis legit

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Unable to get CGI scripts to run
« Reply #14 on: June 24, 2013, 04:19:26 AM »
I can get the exact same script to run OK on my web hosting account so I know that everything is OK in the .pl file but I still get the dreaded "Internal Server Error"

You have to read httpd/error_log to determine what the problem is. Just saying "it doesn't work" isn't sufficient for anyone to help you solve the problem.