Results 1 to 4 of 4
  1. #1
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Script for directory listing

    I have a subdomain containing only graphics. I'd like the default page to dynamically generate a listing of all the files in its directory (clickable links), while not showing subdirectories or parents. I'm guessing that this will only be possible to run server side, and there's already a cgi-bin directory available. The host site doesn't really give much info on what types of scripts can & can't be run, so it may be a bit hit & miss.

    Any suggestions appreciated.

    Alan

    Added - Narrowing down the field, it appears that this site (not mine incidentally) will only support CGI scripts written in Perl, Tcl, C or C++. I have arranged a redirect from the default page, which finds the following sample script OK, but all I can manage is a 500 Internal Server Error - "The server encountered an internal error or misconfiguration and was unable to complete your request." I believe I have set permissions appropriately, and the redirect itself appears to be working. My Perl prowess is marginally above zero.
    <code>
    #!/usr/bin/perl -w

    opendir(DIR, "..");
    @files = grep(/.JPG$/,readdir(DIR));
    closedir(DIR);

    foreach $file (@files) {
    print "$filen";
    }
    </code>

  2. #2
    Plutonium Lounger
    Join Date
    Oct 2001
    Location
    Lexington, Kentucky, USA
    Posts
    12,107
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Script for directory listing

    Well, I think you've already eliminated this as a possibility, Alan (ASP) but maybe there'll be something in <!post=this thread,165842>this thread<!/post> from 2002 in which MarkJ helped me to do just that. If you want to see a sample of what I use it for go here: Files to Download

  3. #3
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Script for directory listing

    Thanks Al. I saw a very similar one on my "hunt", but it certainly seems that PHP and ASP are NOT enabled for this account. Unfortunately I can't telnet in either and test it... it appears there is SSH, which I may have to look into. I'll keep fumbling around for now.

    Alan

  4. #4
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Script for directory listing

    Well, I solved it in Perl, Al. My script was OK, it was mainly setting stuff up on the Linux server... file permissions and all that. Not so much of a learning curve problem, as a rehab program. With Windows you're used to putting your shoes on, then tying the laces. With Linux you have to remember to tie them up first, then put them on, then retie the laces after every step you take in them. <img src=/S/confused.gif border=0 alt=confused width=15 height=20> Anyway, now I have a dynamically-generated, filtered, hyperlinked directory listing.

    Alan

Posting Permissions

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