SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: Code Confusion

Hybrid View

  1. #1
    SitePoint Addict WebMasterAJ's Avatar
    Join Date
    Aug 2000
    Location
    Miami
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This was a toss up between this forum and the Java forum...

    I have a CGI script, and I want to execute it using the java script code:

    Code:
    <SCRIPT SRC="http://216.74.103.162/cgi-bin/jallwall.pl"></SCRIPT>

    This has worked before, but now its not. Here is the CGI file that I'm trying to "convert"

    Code:
    #!/usr/local/bin/perl
    
    $random_file = "/home/username/public_html/directory/random.txt";
    $delimiter = "\n\%\%\%\%\n";
    
    open(FILE,"$random_file") || &error('open->random_file',$random_file);
    @FILE = <FILE>;
    close(FILE);
    
    $phrases = join('',@FILE);
    @phrases = split(/$delimiter/,$phrases);
    srand(time ^ $$);
    $phrase = rand(@phrases);
    print "document.write(Content-type: text/html');\n\n";
    print "document.write('$phrases[$phrase]');\n";
    
    exit;

    What seems to be the problem here?

    Thanks in advance.

    PS: If you know of a Java script file that randomly chooses information from an external file, please tell me.

    Thanks...
    Andrew Tatum
    FinHeaven & Co - Get Drenched With Finformation
    The FinHeaven & Co Forums

  2. #2
    SitePoint Addict WebMasterAJ's Avatar
    Join Date
    Aug 2000
    Location
    Miami
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    anyone?
    Andrew Tatum
    FinHeaven & Co - Get Drenched With Finformation
    The FinHeaven & Co Forums

  3. #3
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Looks like it should work at a glance.

    Try loading the script yourself by typing the following into your browser's address field:

    view-source:http://216.74.103.162/cgi-bin/jallwall.pl

    Do you get any error messages, or does the script produced look wrong in some way?
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  4. #4
    SitePoint Zealot
    Join Date
    Nov 2000
    Posts
    164
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Now I could be completly wrong,
    You code looks ok, but could the file you are opening up, could the permissions not be set correctly.

    Check the permissions of the file you are opening.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •