• Script for directory listing

    Author
    Topic
    #414539

    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.

    #!/usr/bin/perl -w

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

    foreach $file (@files) {
    print "$filen";
    }

    Viewing 0 reply threads
    Author
    Replies
    • #922172

      Well, I think you’ve already eliminated this as a possibility, Alan (ASP) but maybe there’ll be something in this thread 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

      • #922232

        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

      • #922265

        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. confused Anyway, now I have a dynamically-generated, filtered, hyperlinked directory listing.

        Alan

    Viewing 0 reply threads
    Reply To: Script for directory listing

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: