Solved

Dynamically Enumerating Files

Posted on 1998-12-07
3
145 Views
Last Modified: 2013-12-25
I'm looking to make a real simple script.  Heres what I want to accomplish.
Have the script look in a specific directory, enumerate all the ".htm" files and then output in HTML links to those pages in that directory.  I know it's real easy to do, but I have never worked with this before.  It was kind of shoved into my lap.
This is going to be on an NT server running IIS4.0 and Active State.   I'm really unsure on how to enumerate the files, I think I can figure out the HTML output by example, but I haven't seen any examples that would help me out with extracting the file names and such.  If anyone has an example similiar to this or can just help me out it would be really appreciated. Thanks.
=Blain
0
Comment
Question by:timberbt
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 50 total points
ID: 1830042
Here it is in perl:

print "Content-type: text/html<br>\n\n";
my($dir) = "C:\\users\\Powers";
opendir(DIR, $dir) || die "Unable to open $dir: $!";

my(@files) = grep {/\.htm$/i && -f "$dir\\$_"} readdir(DIR);
foreach (@files) {
    print "<a href=\"$dir\\$_\">$_</A><br>\n"
}


0
 
LVL 1

Author Comment

by:timberbt
ID: 1830043
That seems to work great, but I'm having one other problem which may or may not be related.  I can run that just fine from the command prompt on NT, and the HTML looks to be correct.  But when I open it with a browser it will still run the script, ( I see a little command window pop up) but the HTML is not loaded into the browser.  What exactly am I missing?  Thanks!
=Blain
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1830044
It's not related at all... your server is not correctly configured.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
This tutorial will discuss fancy secure registration forms, with AJAX technology support. In this article I assume you already know HTML and some JS. I will write the code using WhizBase Server Pages, so you need to know some basics in WBSP (you mig…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now