Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with FSO Textstream and REGEX

Status
Not open for further replies.

dougcranston

Technical User
Oct 5, 2001
326
US
I am having a problem with scripting a match of a string from a text file.

The file is created by redirecting the output to a tmpfile called physmedia.tmp from RSM

This is to test to see if there is a backup tape in the tape drive.

The file that is created does have the text I am trying to match to which is:

"The command completed successfully."

However nothing displays for either the Winner or Loser.

So I tried moving the following lines to just before the WHILE:

var strLine = ts.ReadLine();
WScript.Echo(strLine);

just to see if anything was being seen.

What I get is "Input past end of file" Error 800A003E

So I have looked at the file and have noted that there is not EOF marker ASCII CTRL-Z

Tried an old DOS trick of creating a file with just the CTRL-Z in it and appending it before running my script.

Nothing is displayed when I moved it back to after the WHILE and still got an error "Input past end of file" message when I left the code prior to the WHILE.

Any suggestions?

Thanks in advance.

Dougc

CODE FOLLOWS:



var tstRE = /The command completed successfully./;

var fso = new ActiveXObject("Scripting.FileSystemObject");
var ts = fso_OpenTextFile("c:\\physmedia.tmp",1,true);

while (!ts.AtEndOfStream)
{
var strLine = ts.ReadLine();
WScript.Echo(strLine);

if (strLine.match(tstRE) == true) {

WScript.Echo("Winner");
}
else {
WScript.Echo("loser");
}
}





 
Issue has been resolved...

Found issue with the regex and now works.

Dougc
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top