Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dynamically Enumerating Files

Posted on 1998-12-07
3
Medium Priority
?
160 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 150 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to count occurrences of each item in an array.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

604 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