473,811 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Directory listing on localhost

I am new to scripting. I am looking for a way to find a filename in a
directory using regular expressions. I do not have a client-server setup
i.e. the directory that I want to search in is local (the same directory
in which the script resides). What functions are used to list one by one
the files in a directory so that I may match the filename with a regular
expression (say to find all files which begin with profile_5). Any
suggestions/pointers will be highly welcome.
Thank you for your help.

Jul 20 '05 #1
16 24988
In article <bo**********@p rometheus.acsu. buffalo.edu>, rg27
@cse.buffalo.ed u enlightened us with...
I am new to scripting. I am looking for a way to find a filename in a
directory using regular expressions. I do not have a client-server setup
i.e. the directory that I want to search in is local (the same directory
in which the script resides). What functions are used to list one by one
the files in a directory so that I may match the filename with a regular
expression (say to find all files which begin with profile_5). Any
suggestions/pointers will be highly welcome.
Thank you for your help.

You can't with normal client-side javascript. ActiveX, WSH, or COM would
(might) let you, browser-dependent and security allowing.

What browser and OS are you using? Also, is this running on your
machine, or a web server?
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #2
kaeli wrote:
You can't with normal client-side javascript. ActiveX, WSH, or COM would
(might) let you, browser-dependent and security allowing.

What browser and OS are you using? Also, is this running on your
machine, or a web server?


Thank you for your reply. I am using Windows 2000 and IE6. The script is
to be run on my machine. As an example say I have a file called
display.html on my hard drive. When I load that file into the
browser(using file:// in the address bar) I want to see a list of files
which match a pattern (say beginning with abc) in the directory in which
display.html resides. This directory is local. So basically I want the
script to interact with the local filesystem and do some filename matching.

Jul 20 '05 #3
Try Perl
Jul 20 '05 #4
In article <bo**********@p rometheus.acsu. buffalo.edu>, rg27
@cse.buffalo.ed u enlightened us with...

Thank you for your reply. I am using Windows 2000 and IE6. The script is
to be run on my machine. As an example say I have a file called
display.html on my hard drive. When I load that file into the
browser(using file:// in the address bar) I want to see a list of files
which match a pattern (say beginning with abc) in the directory in which
display.html resides. This directory is local. So basically I want the
script to interact with the local filesystem and do some filename matching.


Oh, okay. Nope, not javascript. WSH (windows script host).

Try this. Worked fine for me - IE6/Win2KPro.
Set the folder to the one you want (i have wwwroot).
If that works for you, you can modify it to do pattern matching and
stuff. Look up WSH resources, as this is a javascript group. :)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
<title> New Document </title>
</head>

<body>
<script language="vbscr ipt">
'List Files in a particular Directory
Dim fs2, f2, s2, folderspec2, strFileName2

'Specify the path in which directory you want the list of files
folderspec2 = "c:\inetpub\www root"

Set fs2 = CreateObject("S cripting.FileSy stemObject")
Set f2 = fs2.GetFolder(f olderspec2)

For Each FileName In f2.files
s2 = s2 & fileName.name
s2 = s2 & "<br>"
Next

'Close all objects, set to nothing to free up memory.
Document.Write s2
set f2 = nothing
set fs2 = nothing
</script>
</body>
</html>

--
-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #5
Lee
kaeli said:

In article <bo**********@p rometheus.acsu. buffalo.edu>, rg27
@cse.buffalo.e du enlightened us with...

Thank you for your reply. I am using Windows 2000 and IE6. The script is
to be run on my machine. As an example say I have a file called
display.html on my hard drive. When I load that file into the
browser(using file:// in the address bar) I want to see a list of files
which match a pattern (say beginning with abc) in the directory in which
display.html resides. This directory is local. So basically I want the
script to interact with the local filesystem and do some filename matching.


Oh, okay. Nope, not javascript. WSH (windows script host).


Actually, WSH understands Javascript (JScript), too.
Here's an excerpt from one of my HTA's:

<script type="text/javascript">
var fso=new ActiveXObject(" Scripting.FileS ystemObject");

function getScriptList(f olderspec){
var f = fso.GetFolder(f olderspec);
var fc = new Enumerator(f.fi les);
for (; !fc.atEnd(); fc.moveNext()){
var fileName=fc.ite m().Name
if(-1!=fileName.sea rch(/^Install/)){
// do stuff with filename beginning with "Install"
}
}
}

Jul 20 '05 #6
In article <bo*********@dr n.newsguy.com>, RE************* *@cox.net
enlightened us with...

Actually, WSH understands Javascript (JScript), too.
Here's an excerpt from one of my HTA's:

Yeah, but this is running with no server with File-> Open.

Can an HTA do that?
I've never tried and I'm a bit of a newbie to HTAs. Too many Unix users
here that use Netscape for it to be a valid work project. I just muck
around with them a bit on my own computer.

Your script looks like it should run with just a browser...does it?

A bit OT, but what's the difference between an HTA and a WSH script, if
any?

-------------------------------------------------
~kaeli~
Jesus saves, Allah protects, and Cthulhu
thinks you'd make a nice sandwich.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #7
Lee
kaeli said:

In article <bo*********@dr n.newsguy.com>, RE************* *@cox.net
enlightened us with...

Actually, WSH understands Javascript (JScript), too.
Here's an excerpt from one of my HTA's:
Yeah, but this is running with no server with File-> Open.

Can an HTA do that?


Yes. I think that it can be done in Javascript in the same
environments that it can be done with VBScript, but I won't swear.

I've never tried and I'm a bit of a newbie to HTAs. Too many Unix users
here that use Netscape for it to be a valid work project. I just muck
around with them a bit on my own computer.

Your script looks like it should run with just a browser...does it?
I believe it will run in IE, with an appropriate warning about ActiveX.
I can't test it at the moment.
A bit OT, but what's the difference between an HTA and a WSH script, if
any?


The biggest difference is than an HTA runs in a window whose content
is decribed in HTML, so it's a simple way to create a GUI in a Windows
environment.

The example I posted was from an application that presents a list of
software choices to be installed on the user's desktop. It had to
be able to run before they have Perl or Tcl installed, and I wanted
it to be a script. WSH scripts are executed in the background to do
the actual installs.

I miss the days when all of my users were on Unix.

Jul 20 '05 #8
On Tue, 04 Nov 2003 13:00:06 -0800, Lee wrote:
I miss the days when all of my users were on Unix.


You mean you miss yer previous job? :D You could get it back ya know...
Move to India. ;)

Jul 20 '05 #9

"Lee" <RE************ **@cox.net> wrote in message news:bo******** *@drn.newsguy.c om...
kaeli said:

In article <bo*********@dr n.newsguy.com>, RE************* *@cox.net
enlightened us with...

Actually, WSH understands Javascript (JScript), too.
Here's an excerpt from one of my HTA's:
Yeah, but this is running with no server with File-> Open.

Can an HTA do that?


Yes. I think that it can be done in Javascript in the same
environments that it can be done with VBScript, but I won't swear.

I've never tried and I'm a bit of a newbie to HTAs. Too many Unix users
here that use Netscape for it to be a valid work project. I just muck
around with them a bit on my own computer.

Your script looks like it should run with just a browser...does it?


I believe it will run in IE, with an appropriate warning about ActiveX.
I can't test it at the moment.
A bit OT, but what's the difference between an HTA and a WSH script, if
any?


An HTA does not run in the Security Context of the Browser. When you launch an HTA, the executable
that hosts it is MsHTA.exe, which among other things allows client side scripting to interact with
the local file system.


The biggest difference is than an HTA runs in a window whose content
is decribed in HTML, so it's a simple way to create a GUI in a Windows
environment.

The example I posted was from an application that presents a list of
software choices to be installed on the user's desktop. It had to
be able to run before they have Perl or Tcl installed, and I wanted
it to be a script. WSH scripts are executed in the background to do
the actual installs.

I miss the days when all of my users were on Unix.

Jul 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2540
by: xEM | last post by:
I have in Apache2 (win32) aliased directory, for example: Alias /ftp/mp3/ "D:/mp3/" <Directory "D:/mp3"> .... </Directory> Address to this directory will be: http://localhost/ftp/mp3/ How can i list files in that directory?
19
3317
by: SU News Server | last post by:
I've struggled with this for quite a while and I'm am just not sure what is going on. I have the following code import os def buildList( directory='/Users/mkonrad' ) dirs = listing = os.listdir(directory)
2
3377
by: Tom | last post by:
I need to get a directory listing through http. If I put the directory path in the browser address bar such as http://somewebpage.com/subdir I get the listing of the directory. Of course this is returned to my client in html. To get the directory listing from this I would need to do some intersting parsing. ftp is not enabled and so I can't do an "ls" through some ftp client. Is there some way in C# to get a directory listing using...
16
11815
by: B Letts | last post by:
Hi - I'm currently using the FileUpload control to allow people to upload files to my website. This all works fine, as long as I'm going to a physical path on my server. However, I need to allow people to upload to a virtual directory. The directory may or may not exist on the same server as the Web site. I can't seem to figure out how to do this. If I pass the virtual
8
11068
by: gil | last post by:
Is it possible to prevent a browser from listing the entire contents of a folder? The site, is hosted on my ISP with the following layout- site/ "user name from ISP" pagefile (dir) index.html site/pagefile/
6
3320
by: David | last post by:
Hi all, Using C# .NET 1.1 I am creating a CMS type of application. So far so good. I have a templating system in place that works fantastically. I can remap non-real files and folders and get the CMS system to handle it. This is working quite cool. I have a 404 handler in place which helps to manage the non-real files and folders. This is done at IIS level rather than .NET level. There is a reason
7
5500
by: epikto | last post by:
I have a mapped share that I am trying to get a listing of all the files that it contains. I use the following code to access the contents String files = Directory.GetFiles(path); I can then enumerate through that array to get my listing. However I am trying to set my application up as a service. And now (after calling methods in a thread using the OnStart() method) it says the directory does not exist (I verified this with a...
4
3252
by: techusky | last post by:
I have a *very* simple script written that displays the directory listing of the current working directory, but I am having some difficulty when I try to change folders. Basically, I have my $dir variable set to this: --- $dir = getcwd() . "\\" . $nav; --- but for some reason the script does not actually display the contents of the directory if you change from the directory the script is located in. Here is my code if someone is willing...
1
5675
by: Steve | last post by:
My site is hosted on a Godaddy reseller site. Godaddy only allows the use of Curl to access remote sites. What is the method for listing a directory after connecting to the site with Curl? I've already tested my code for connecting but how do I list whats in the directory. The purpose is to compare the list to the filenames in my database.
0
10652
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10395
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9211
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7673
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5700
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4346
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3874
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3026
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.