Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 292
  • Last Modified:

cgi script problem

Can you tell me if you see any errors with the script below...I keep getting internal server errors for some reason.. I am sure the path to send mail and perl is correct..any advice would be apreciated...

#!/usr/bin/perl
$|++;
use CGI;
use CGI::Carp 'fatalsToBrowser';  # Remove when script works 100%

$query = new CGI;
$fullname=$query->param('fullname');
$email=$query->param('email');
$problem=$query->param('problem');
open(MAIL, "|/usr/sbin/sendmail ") || die $!;
print MAIL "From: $fullname<$email>\n";
print MAIL "To: samgonzales\@talk21.com.com\n";
print MAIL "Subject: Kragoo.com Request !!!\n";
print MAIL "\n";
print MAIL "Full Name    : $fullname\n";
print MAIL "eMail        : $email\n";
print MAIL "Problem      : $problem\n";
close (MAIL) || die $!;

open(MAIL,"|/usr/sbin/sendmail ") || die $!;
print MAIL "To: $email\n";
print MAIL "From: support\@krooga.co.uk\n";
print MAIL "Subject: RE: Krooga support\n";
print MAIL "\n";
print MAIL "Thank-you for contacting us at kragoo.com,\n";
print MAIL "we have received your Question/Message and\n\n";
print MAIL "we are working hard to respond to you as fast\n";
print MAIL "as possible. You should receive an answer from\n";
print MAIL "us very soon.\n\n";
print MAIL "Thanks again,\n\n";
print MAIL "The Kragoo Support Team\n";
print MAIL "http://www.kragoo.com\n\n";
close (MAIL) || die $!;

print "Content-type: text/html\n\n";
open(HANDLE,"/home/sites/www.kragoo.co.uk/web") || die $!;
while(<HANDLE>) {
s/grfx/..\/grfx/g;
print;
}
0
samgonzales
Asked:
samgonzales
  • 4
  • 4
  • 2
  • +6
1 Solution
 
holliCommented:
0
 
holliCommented:
make sure you did the ftp-upload in ascii-mode!

make sure you have the correct permissions (chmod 755 filename) set!
0
 
bebonhamCommented:
$query=new CGI;
print $query->header;
print $query->start_html();

it's worth a try.

if you are still getting errors, you should run the script in shell, and then tell us the error.

Bob
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

 
rag2000Commented:
print "Content-type: text/html\n\n";
open(HANDLE,"/home/sites/www.kragoo.co.uk/web/pagename.html") || die $!;
while(<HANDLE>) {
$_=~s/grfx/..\/grfx/g;
print $_;
}
0
 
rag2000Commented:
on the shell prompt try 'perl -cw scriptname.cgi'
0
 
bebonhamCommented:

yeah, try it in shell.

as a matter of practice, you should be using or with your dies, not ||, something about || binding to strongly...
0
 
ahoffmannCommented:
this script cannot work (except you have an unusual sendmail). sendmail need its recipients on command line, means that your
     print MAIL "To: $email\n";
is useless, somehow. Also
     print MAIL "From: support\@krooga.co.uk\n";
probably does not what you expect.
0
 
rag2000Commented:
I disagree with ahoffmann... the statement is correct... further the sendmail line modified to

"|/usr/sbin/sendmail -t

the switch '-t' added to it
0
 
ahoffmannCommented:
right, -t option should also do the job.
0
 
samgonzalesAuthor Commented:
ok thanks for the advice so far, can you guys tell me how I can run the CGI script in shell...Also this is how my ftp directory looks :

/Certs/
/Logs/
/Users/
/Web/

I am currently using the script at :
/users/kragoo/contactus.cgi

can this be the problem ? Do I have to put it in the /Web/ folder ? Should I create a CGI-BIN directory ?

Thanks For your help ...I really apreciate it...

Sam ;-)
0
 
ahoffmannCommented:
perl /users/kragoo/contactus.cgi
# or simply
/users/kragoo/contactus.cgi

should start your sript in the shell. 'cause of the "use CGI" it will prompt you to define CGI-variables, where you may type
   fullname=full name

and so on 'til you have all variables set, then finish wirh ^D . That's it.
0
 
rag2000Commented:
yes, you will definitely need a cgi-bin directory with executable rights and the script also needs to have executable rights.... it would be best to get your host to look into this if you can't solve it yourself, since the script is absolutely correct with the modifications suggested... if you want to see it working let me know
0
 
samgonzalesAuthor Commented:
Hello,
I tried what you guys have told me but it doesn't work ...
I get an error saying :

CGIWrap Error: Execution of this script not permitted
Execution of (cgi-bin/contactus.cgi) is not permitted for the following reason:

Script does not have same UID

If someone could fix this for me that would be great:

FTP ADDRESS ==> www.kragoo.co.uk
USERNAME ==> krooga
PASSWORD ==> pleasefixit

What I want to happen is that when someone goes to the contact us page and fills the form in :
1. The message/question is sent to my e-mail
2. Their e-mail is added to a text file that I can use to send newsletters in the future. (Checks that the address is not allready in the list)
3. A message is sent back to them saying that the krooga support team will reply shortly to their query

If you could log on to my FTP account and fix this that would be great. Telling me what I done wrong and how you went about fixing it would be even better...

Thanks

Sam ;-)

0
 
ahoffmannCommented:
you need to tell your (Web)admin to give the cgi-script the appropriate permisions and user. That's all.
0
 
Schells_Web_DesignCommented:
There is a really strange problem with your website. Maybe I'm missing something.

Whenever I try to bring up any files - I get the response that they are not available. I think it's more than a matter of setting permissions. I set them for you via FTP but the file is not being read by the server.

It looks as if  you are running on a Cobalt server - ask your host these things:

1. Are you set-up to run cgi programs? (Cobalt allows cgi without a cgi-bin folder)
2. What extension do they prefer you use? cgi or pl
3. There is also a weird security thing on the Cobalt servers that gives Wrap errors. The host will have a special setting to change to use some scripts.
4. Your script is calling a 'data1' directory to get your file to store information (I am assuming that is what it is doing) - do you have full access to that file via the root path? Does that file have the right permissions?

Does that help?
0
 
maneshrCommented:
samgonzales,

Did you get the solution you were looking for?

What solution, if any, did you use??

Please let us know.

If you have already found the solution on your own or this question has become obsolete, please go ahead and delete this question.

Thanks,
0
 
MoondancerCommented:
Please update/finalize this question.

Thanks,

Moondancer
Community Support Moderator @ Experts Exchange
0
 
Computer101Commented:
Points reduced to 67, comment from expert accepted as answer.  bebonham and rag2000, look for your questions in this topic area.

Computer101
E-E Moderator
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 4
  • 4
  • 2
  • +6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now