dougcranston
Technical User
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 = fs
penTextFile("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");
}
}
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 = fs
while (!ts.AtEndOfStream)
{
var strLine = ts.ReadLine();
WScript.Echo(strLine);
if (strLine.match(tstRE) == true) {
WScript.Echo("Winner");
}
else {
WScript.Echo("loser");
}
}