CGI and moving servers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sorcerer2066
    New Member
    • Jun 2006
    • 3

    CGI and moving servers

    Has anyone got a few minutes to spare to help me with a page that wont load.


    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
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    It could be an error in signup.cgi itself

    Comment

    • sorcerer2066
      New Member
      • Jun 2006
      • 3

      #3
      thanks

      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

      Comment

      • sorcerer2066
        New Member
        • Jun 2006
        • 3

        #4
        This is the code

        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_ST RING'} =~ /signup/){
        &createsignu p;
        }
        elsif ($ENV{'QUERY_ST RING'} =~ /createaccount/){
        &createsignu p;
        }
        else{
        &signup;
        }

        sub createsignup{
        $cgi = new CGI;

        $username = $cgi->param('usernam e');
        $password = $cgi->param('passwor d');
        $password2 = $cgi->param('passwor d2');
        $emailaddress = $cgi->param('emailad dress');

        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($userna me) > 10 || length($usernam e) < 4){
        $diemessage = "The username you have entered is either too long or too short.";
        &signup;
        exit;
        }
        if (length($passwo rd) > 10 || length($passwor d) < 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\@yah oo.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_A DDR'}\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,"<$fi lename");
        @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;
        }

        Comment

        • Banfa
          Recognized Expert Expert
          • Feb 2006
          • 9067

          #5
          OK Perl really is my bag so I've had to read up about it but here are a couple of things to try

          Originally posted by sorcerer2066
          ------------------------
          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

          Code:
          #!/usr/bin/perl 
          
          print "Content-type: text/html\n\n";
          
          print "<html><head><title>Test</title></head><body><p>Hello World!</p></body></html>";
          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.

          Comment

          Working...