By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,474 Members | 939 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,474 IT Pros & Developers. It's quick & easy.

CGI and moving servers

P: 3
Has anyone got a few minutes to spare to help me with a page that wont load.
http://www.yachtcrew-cv.com/cgi-bin/cv/admin/signup.cgi

Evidently it is the pathway and CHMOD that's wrong but I tried changing it and it still wont load.

If you can help I will send you further info and maybe you can spot where the glitch is.

Thanks very much

Jen
Jun 13 '06 #1
Share this Question
Share on Google+
4 Replies


Banfa
Expert Mod 5K+
P: 8,916
It could be an error in signup.cgi itself
Jun 13 '06 #2

P: 3
Hi Banfa

Thanks so much for replying. The script has been working for three years. It's only moving it to the new server that it's started to give me grief.

If you don't mind looking at it I will post it here. If you could help I would be so grateful.

Thanks

Jen
Jun 13 '06 #3

P: 3
Below is the cgi code where I can't get the page to load but first is the mail I get from the hosts. Please please tell me what to change. How do I change paths etc :confused:
------------------------
Your website's path to Perl is usr/bin/perl and this is only for files with the .pl file extension.
The path to your cgi bin is either:
/home/virtual/yourdomain.com/var/www/cgi-bin
but if that does not work then try:
/var/www/cgi-bin

----------------------------------
Here is the actual code :eek:


#!/usr/bin/perl

print "Content-type: text/html\n\n";

use CGI;

if ($ENV{'QUERY_STRING'} =~ /signup/){
&createsignup;
}
elsif ($ENV{'QUERY_STRING'} =~ /createaccount/){
&createsignup;
}
else{
&signup;
}

sub createsignup{
$cgi = new CGI;

$username = $cgi->param('username');
$password = $cgi->param('password');
$password2 = $cgi->param('password2');
$emailaddress = $cgi->param('emailaddress');

if (!$username){
$diemessage = "You have not entered a username.";
&signup;
exit;
}
if (!$password){
$diemessage = "You have not entered a password.";
&signup;
exit;
}
if ($password ne $password2){
$diemessage = "The two password you have entered are invalid.";
&signup;
exit;
}
if (!$emailaddress){
$diemessage = "You have not entered your email address.";
&signup;
exit;
}
if ($username !~ /^[a-zA-Z0-9_]+$/){
$diemessage = "You have entered an invalid username.";
&signup;
exit;
}
if ($password !~ /^[a-zA-Z0-9_]+$/){
$diemessage = "You have entered an invalid password.";
&signup;
exit;
}

if (length($username) > 10 || length($username) < 4){
$diemessage = "The username you have entered is either too long or too short.";
&signup;
exit;
}
if (length($password) > 10 || length($password) < 4){
$diemessage = "The password you have entered is either too long or too short.";
&signup;
exit;
}
if (-e "../profiles/$username.pro"){
$diemessage = "The username you have selected already exists within the database.";
&signup;
exit;
}

mkdir("../cv/$username", 0777);
mkdir("../../../public_html/cv/$username", 0777);

open(SEND,"|/usr/sbin/sendmail -t");
print SEND "To: $emailaddress\n";
print SEND "From: merlin2066\@yahoo.com\n";
print SEND "Subject: CV Account Signup Successful\n";
print SEND <<endMAIL;

Hi,

Services to the Superyacht industry
endMAIL
close(SEND);

$password = crypt($password, "MM");

#create the profile
open(PRO,">../profiles/$username.pro");
flock(PRO,2);
print PRO "$username\n";
print PRO "$password\n";
print PRO "$emailaddress\n";
print PRO "$ENV{'REMOTE_ADDR'}\n";
flock(PRO,8);
close(PRO);

@html = htmlscope('../html/confirm.htm');
print "@html";
exit;
}

sub signup{
if ($diemessage eq ""){
$diemessage = "Please enter the fields below to create a membership account.";
}

@html = htmlscope('../html/signup.htm');
print "@html";
exit;
}

sub htmlscope{
$filename = shift;

open(HTML,"<$filename");
@html = <HTML>;
close(HTML);

foreach $line (@html){
if ($line =~ /\$/g || $line =~ /\@/){
@letters = split(/|/, $line);
$inside = 0;
foreach $letter (@letters){
chomp($letter);
if (!($letter =~ /^[a-zA-Z0-9_\{\}\']+$/)){
$inside = 0;
}
if ($inside == 1){
$string .= $letter;
}
else{
if ($letter =~ /\$/ || $letter =~ /\@/){
if ($string =~ /\$/g || $string =~ /\@/g){
$string .= "\n$letter";
}
else{
$string .= $letter;
}
$inside = 1;
}
}
}
if ($string =~ /\n/g){
@multivars = split(/\n/, $string);
foreach $var (@multivars){
push(@variables, $var);
}
}
push(@variables, $string);
foreach $var (@variables){
chomp($var);
if ($var =~ /\$/g){
$var =~ s/\$//gi;
$line =~ s/\$$var/$$var/gi;
}
else{
$var =~ s/\@//gi;
$line =~ s/\@$var/@$var/gi;
}
}
$found = 0;
$string = "";
}
}

return @html;
}
Jun 13 '06 #4

Banfa
Expert Mod 5K+
P: 8,916
OK Perl really is my bag so I've had to read up about it but here are a couple of things to try

------------------------
Your website's path to Perl is usr/bin/perl and this is only for files with the .pl file extension.
The path to your cgi bin is either:
/home/virtual/yourdomain.com/var/www/cgi-bin
but if that does not work then try:
/var/www/cgi-bin

----------------------------------
Here is the actual code :eek:


#!/usr/bin/perl
The path in the email has no / at the beginning of it but you have a / at the beginning of the shbang.

Try the simplest script you can to test the shbang line

Expand|Select|Wrap|Line Numbers
  1. #!/usr/bin/perl 
  2.  
  3. print "Content-type: text/html\n\n";
  4.  
  5. print "<html><head><title>Test</title></head><body><p>Hello World!</p></body></html>";
  6.  
It this works great, if not get help from your host.

If this does work then I would guess you need to look to the paths in your script to see if they are correct.

Test the function htmlscope but creating a script that contains only this function and a call to it.

You have several relative paths in the scripts (when open files and creating directories, paths including .. ), try replacing them with absolute paths.


The script is long and a little complex so you need to simplify it while you find the problem, once you have found it you can then correct the original script.
Jun 14 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.