Koozali.org: home of the SME Server

Unable to get CGI scripts to run

Offline TerryF

  • grumpy old man
  • *
  • 1,847
  • +6/-0
Re: Unable to get CGI scripts to run
« Reply #15 on: June 24, 2013, 05:01:05 AM »
What was the url that you put in the Dansie contact form?
 
It should have been in this form <FORM ACTION="http://ddj.homelinux.com/cgi-bin/mail_ht.pl" METHOD=POST>

I setup up the contact form as per the Dansie website and it worked as it should.
« Last Edit: June 24, 2013, 05:27:00 AM by TerryF »
--
qui scribit bis legit

Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #16 on: June 24, 2013, 06:59:29 AM »
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.

Logs are posted further up in reply #4, but this is all it says -

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.

Form/script works fine on a shared hosting account I have, just can't seem to get it to work on my server.
« Last Edit: June 24, 2013, 07:03:46 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 janet

  • *****
  • 4,812
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #17 on: June 24, 2013, 08:24:07 AM »
del

Quote
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

Please run these commands & show the actual output of
cd /home/e-smith/files/ibays/Primary/
ls -al

and

cd /home/e-smith/files/ibays/Primary/cgi-bin/
ls -al

Please search before asking, an answer may already exist.
The Search & other links to useful information are at top of Forum.

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Unable to get CGI scripts to run
« Reply #18 on: June 24, 2013, 03:42:50 PM »
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

Show output of:

ls -l /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl
file /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl

What happens if you type just:

/home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl

?

Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #19 on: June 24, 2013, 04:48:14 PM »
Hi Janet,
When I run
cd /home/e-smith/files/ibays/Primary/
ls -al
I get this
Quote
total 20
drwxr-xr-x 5 root  root   4096 Jun 21 20:43 .
drwxr-xr-x 5 root  root   4096 Jun 20 22:01 ..
drwxr-xr-x 2 root  root   4096 Jun 23 09:29 cgi-bin
drwxr-s--- 2 admin shared 4096 Aug  1  2012 files
drwxr-s--- 3 admin shared 4096 Jun 23 16:07 html
and when I run
cd /home/e-smith/files/ibays/Primary/cgi-bin/
ls -al
I get this
Quote
total 24
drwxr-xr-x 2 root root  4096 Jun 23 09:29 .
drwxr-xr-x 5 root root  4096 Jun 21 20:43 ..
-rwxr-xr-x 1 root root 13937 Jun 21 20:44 mail_ht.pl

Hi Charlie,
When I run
Quote
ls -l /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht
.pl
I get
Code: [Select]
-rwxr-xr-x 1 root root 13937 Jun 21 20:44 /home/e-smith/files/ibays/Primary/cgi-
bin/mail_ht.pl
When I run
Quote
file /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl
I get
Code: [Select]
/home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl: perl script text executableand finally if I run
Quote
/home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl
I get
Code: [Select]
-bash: /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl: /usr/bin/perl^M: bad interpreter: No such file or directory
Thank you both for taking the time to look and help.

Kind 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 _alex

  • ****
  • 103
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #20 on: June 24, 2013, 05:00:39 PM »
Hi,

Your problem is that the perl script has windows style lines endings (carriage return + line feed)

You can fix it by running:
Code: [Select]
dos2unix -o /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: Unable to get CGI scripts to run
« Reply #21 on: June 24, 2013, 05:45:49 PM »
Quote
-bash: /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl: /usr/bin/perl^M: bad interpreter: No such file or directory

dos2unix /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl

Offline del

  • *
  • 765
  • +0/-0
Re: Unable to get CGI scripts to run
« Reply #22 on: June 24, 2013, 06:01:31 PM »
Hi,

Your problem is that the perl script has windows style lines endings (carriage return + line feed)

You can fix it by running:
Code: [Select]
dos2unix -o /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl

dos2unix /home/e-smith/files/ibays/Primary/cgi-bin/mail_ht.pl

Thank you both, that fixed it! Thank you to everyone who offered their help and time.
One question, what should I use to edit these files on a Windows PC? Is there anyway I can prevent this from happening next time? Thanks again.

Kind 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 Stefano

  • *
  • 10,894
  • +3/-0
Re: Unable to get CGI scripts to run
« Reply #23 on: June 24, 2013, 06:04:55 PM »
One question, what should I use to edit these files on a Windows PC? Is there anyway I can prevent this from happening next time?

yes, don't use windows to edit such a file..
nano/pico/vi/whatever and you are done

Offline TerryF

  • grumpy old man
  • *
  • 1,847
  • +6/-0
Re: Unable to get CGI scripts to run
« Reply #24 on: June 25, 2013, 12:15:18 AM »
I use perledit http://www.indigostar.com/perledit.php free for pers use
--
qui scribit bis legit