Random Image script not working please help

Discussion in 'Programming' started by Riots, Jul 1, 2007.

  1. #1
    I got this random script image but its not working right any help?

    Heres link to my page here and heres the code to the script

    and I was told to just use src = (the path to script) on the page i want to show random images..

    #! /usr/local/bin/perl
    
    # Necessary Variables
      $basedir = "http://www.graffintheno/newsite/gallery/images/";
      @files = ("Graffiti_Photo_007.jpg","Graffiti_Photo_008.jpg","Graffiti_Photo_009.jpg","Graffiti_Photo_010.jpg");
    
    # Options
      $uselog = 0; # 1 = YES; 0 = NO
            $logfile = "/home/mattw/public_html/image/pics/piclog";
    
    # Done
    ##############################################################################
    
    srand(time ^ $$);
    $num = rand(@files); # Pick a Random Number
    
    # Print Out Header With Random Filename and Base Directory
    print "Location: $basedir$files[$num]\n\n";
    
    # Log Image
    if ($uselog eq '1') {
        open (LOG, ">>$logfile");
        print LOG "$files[$num]\n";
        close (LOG);
    }
    
    Code (markup):
     
    Riots, Jul 1, 2007 IP
  2. SomniOne

    SomniOne Well-Known Member

    Messages:
    136
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    128
    #2
    My guess is (without checking the script) would be that it's not executable, or you don't have a execute permission in that directory, or yet the perl location is not correct (/usr/local/bin/perl)
    Try with:
    #!/usr/bin/env perl
    And try setting the execute permission

    Or simply try putting:
    -------
    print "Hello world";
    exit;
    ------
    just after the first line to confirm that the script actually executes and call it directly. Also your server's error log at the time of calling could give you a hint.
     
    SomniOne, Jul 4, 2007 IP