Solved

Dynamically Enumerating Files

Posted on 1998-12-07
3
158 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently I have been answering a lot of questions like this in IT forums that I frequent. The question posed is usually something along the lines of "We have software X installed and need to uninstall it for reason Y" or some other variant of the sa…
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
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…

687 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