Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

cgi script problem

Posted on 2001-07-23
18
Medium Priority
?
287 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
  • 4
  • 4
  • 2
  • +6
18 Comments
 
LVL 6

Expert Comment

by:holli
ID: 6309815
0
 
LVL 6

Accepted Solution

by:
holli earned 268 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
[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

916 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