Solved

Dynamically Enumerating Files

Posted on 1998-12-07
3
154 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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Convert MSI to MSM 1 75
What is assert.deepEqual? 4 53
Questions about this React unit test 4 66
change the windows script file to BAT 10 49
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…

856 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