Solved

cgi script problem

Posted on 2001-07-23
18
281 Views
Last Modified: 2013-12-25
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
Comment
Question by:samgonzales
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 2
  • +6
18 Comments
 
LVL 6

Expert Comment

by:holli
ID: 6309815
0
 
LVL 6

Accepted Solution

by:
holli earned 67 total points
ID: 6309822
make sure you did the ftp-upload in ascii-mode!

make sure you have the correct permissions (chmod 755 filename) set!
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6310452
$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
The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

 
LVL 3

Expert Comment

by:rag2000
ID: 6312104
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
 
LVL 3

Expert Comment

by:rag2000
ID: 6312106
on the shell prompt try 'perl -cw scriptname.cgi'
0
 
LVL 8

Expert Comment

by:bebonham
ID: 6312458

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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6313818
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
 
LVL 3

Expert Comment

by:rag2000
ID: 6313843
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6313933
right, -t option should also do the job.
0
 

Author Comment

by:samgonzales
ID: 6313937
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6313960
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
 
LVL 3

Expert Comment

by:rag2000
ID: 6313967
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
 

Author Comment

by:samgonzales
ID: 6327652
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6329501
you need to tell your (Web)admin to give the cgi-script the appropriate permisions and user. That's all.
0
 
LVL 2

Expert Comment

by:Schells_Web_Design
ID: 6358111
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
 
LVL 16

Expert Comment

by:maneshr
ID: 6628500
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
 
LVL 1

Expert Comment

by:Moondancer
ID: 6699411
Please update/finalize this question.

Thanks,

Moondancer
Community Support Moderator @ Experts Exchange
0
 
LVL 1

Expert Comment

by:Computer101
ID: 6904043
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

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial will discuss the log-in process using WhizBase. In this article I assume you already know HTML. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you might look at some of my other articles abo…
In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question