Click to See Complete Forum and Search --> : List Script


Chopper WeeD
05-19-2003, 10:50 PM
Does any one know how i can create a simple index page that will list the files in that directory with a link to them.

AdamBrill
05-19-2003, 11:02 PM
Well, I don't think it can be done without server-side code. Which server-side languages does your server support?

Chopper WeeD
05-23-2003, 04:18 AM
I contacted my ISP and they said they support HTML and CGI Scripts

Charles
05-23-2003, 04:54 AM
#!usr/local/bin/perl
use CGI qw(:all);
my @dir = map {a({-href => $_, -type=>"text/html"}, $_)} <*.html>;
print header, start_html (title => 'Index'), h1('Index'), ul(li(\@dir)), end_html;

Chopper WeeD
05-23-2003, 05:03 AM
Thanks, but unfortuantly, I have no idea what you have just said.

I dont know where to start with pearl, and unless that code was in tutorial form, i wouldnt know how to use it.

If you could help further, it would be greatly appreciated.

Thanks
Chopper

pyro
05-23-2003, 07:23 AM
Charles- That will only list the .html files, shouldn't he use this to list them all?

#!/usr/bin/perl
use CGI qw(:all);
my @dir = map {a({-href => $_, -type=>"text/html"}, $_)} <*.*>;
print header, start_html (title => 'Index'), h1('Index'), ul(li(\@dir)), end_html;

Charles
05-23-2003, 09:04 AM
Who knows? My chrystal ball is at the cleaners so that script is going to need a little tweaking.

. The shebang line, #!user/local/bin/perl, is specific to your server so Chopper WeeD'll have to find out what to use from the server folks.

. If you want this to work on some other directory, then you'll need to add a chdir some/directory; line before the file glob.

. And the file glob, <*.*>, should reflect the wanted files.

. And of course, the print line needs a little adjustment to make the output a little more interesting.

pyro
05-23-2003, 09:36 AM
I just made an asumption from the original post that he wanted to list all the files. I could certainly be wrong...

Chopper WeeD
05-23-2003, 02:21 PM
Yes, Pyro is correct there, I do want to list more than html files. Mainly jpg & gif.

This is all the Inforamtion my ISP gave me, which wasnt very helpful.

The Telstra BigPond(TM) server provides limited support for CGI (Common Gateway Interface)
scripts, more information can be found at:

http://www.bigpond.com/broadband/memservices/webhosting/cgi/

Please note that this is a service provided free of charge to members and there is no
technical assistance available for CGI scripts.


Also, where do I place this script. Im assuming it goes in the body of a html file.

AdamBrill
05-23-2003, 03:44 PM
Does it say that you can use custom scripts? In order to use these, you would have to be on a server that supports custom CGI scripts. You might want to try writing them and asking if they support them... ;)

Chopper WeeD
05-23-2003, 09:53 PM
I have sent my ISP a new message, but I'm unsure if they will reply to it.

If they dont I will ring them.

FrequeNC
05-24-2003, 05:20 PM
I think I know what you are talking about. I stumbled upon it by accident one time, I am not sure that I can tell you exactly what to do, but just try putting all the files in your directory the way you normally would, but do not include an index.htm page. By default it will list everything that you have in the directory. (example - if you have dumped everything into your root directory, 10 images for example, without putting them into their own folder - it will list them:

1.jpg
2.jpg
3.jpg
4.jpg
5.jpg
...
...
...

and each of them are a direct link to the actual file.

Try that and see if it works. Like I said - I came upon that by accident - by not naming my files correctly, so it is something to do with the naming convention as it relates to your root page being called either index, start, or default.

Hope that helps.

Chopper WeeD
05-25-2003, 11:41 PM
Here is my reply from my ISP

Dear Mr ####,

Thank you for your email dated 24/5/03, regarding CGI scripting support.

The only 3 CGI scripts that are supported on the free 10mb websites are;

*A hit counter
*A clock
*A form to email

We do have Pearl server-side language, however only those 3 scripts have been allowed for
the free 10mb websites, which rules out custom scripts.

but just try putting all the files in your directory the way you normally would, but do not include an index.htm page. By default it will list everything that you have in the directory

That was my Original thought, but i wont work for me where my files are kept. which is http://users.bigpond.net.au/chopperweed/misc/

Anyone have any other ideas?


Thanks
Chopper

FrequeNC
05-26-2003, 04:29 AM
Can you ftp to your site? If so, you ought to be able to do that. Or else - if you are just trying to get a listing of the media in a directory, why not just list them, and to make them as a download (like if someone clicks on a link and it prompts a download, or they can (PC) right click - save target as or (MAC) cntrl click - save target as

instead of linking to a html page that displays the media, you link directly to the media - like instead of a page which contains a jpg image

<a href = "image.html"> open page </a>

you would link like this

<a href = "imageName.jpg"> file name here </a>

Does that help any more?

Charles
05-26-2003, 06:10 AM
Yes, the obvious solution is to update index file yourself each time you add or remove a file to the directory. If you keep a local copy of the directory then you can use that script locally to generate the index file for you. And if you are using Windows &trade; then you can download Perl from ActiveState (http://www.activestate.com/). I use Perl locally for that kind of thing all of the time.

Chopper WeeD
05-26-2003, 09:39 AM
Yes, I do keep a back up folder on my pc and I also use ftp to upload. Went to get perl but there where alot of files, what files do i need to run this small script. Or better yet, is there a program that can also do this.