Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Do while fso.FileExists() question

Reply
 
Old 02-10-2009   #1 (permalink)
JumboShrimps


 
 

Do while fso.FileExists() question

Have a log file from a ftp session started with vbs script.

This script:
1. Downloads the ftp log to my local hard drive as "c:\ftp.log"
2. Opens "ftp.log" for reading.
3. Read one line at a time.
4. If string "Yada-Yada" is found in "ftp.log"
(usually in the 1st or 2nd line)
data set on MVS mainframe is ready to be downloaded,
5 Open another ftp session and download mainframe data set
6. fso.DeleteFile("c:\ftp.log") and exit sub

However, if the string "Yada-Yada" is NOT found in "ftp.log" then
Wscript.sleep xxxxxx
start another ftp session starting back at step #1.

Keep running this ftp script every "X" (wscript.sleep) number of
minutes
until the MVS mainframe job is complete as evidenced in the
refreshed "c:\ftp.log" on my hard drive.
MVS job could take hours.

I tried Do While fso.FileExists("c:\ftp.log")
with ftp.log being deleted
via fso.DeleteFile("ftp.log") upon successful
reading of the "Yada-Yada" string
(so that should stop the process as "C:\ftp.log" no longer
exists????)
but it seems cumbersome, not to mention it doesn't work.

How would I loop back through a process, terminating only if a certain
string is found in a file that is re-downloaded every "X" number of
minutes?

My System SpecsSystem Spec
Old 02-10-2009   #2 (permalink)
Todd Vargo


 
 

Re: Do while fso.FileExists() question

JumboShrimps wrote:
Quote:

> Have a log file from a ftp session started with vbs script.
>
> This script:
> 1. Downloads the ftp log to my local hard drive as "c:\ftp.log"
> 2. Opens "ftp.log" for reading.
> 3. Read one line at a time.
> 4. If string "Yada-Yada" is found in "ftp.log"
> (usually in the 1st or 2nd line)
> data set on MVS mainframe is ready to be downloaded,
> 5 Open another ftp session and download mainframe data set
> 6. fso.DeleteFile("c:\ftp.log") and exit sub
>
> However, if the string "Yada-Yada" is NOT found in "ftp.log" then
> Wscript.sleep xxxxxx
> start another ftp session starting back at step #1.
>
> Keep running this ftp script every "X" (wscript.sleep) number of
> minutes
> until the MVS mainframe job is complete as evidenced in the
> refreshed "c:\ftp.log" on my hard drive.
> MVS job could take hours.
>
> I tried Do While fso.FileExists("c:\ftp.log")
> with ftp.log being deleted
> via fso.DeleteFile("ftp.log") upon successful
> reading of the "Yada-Yada" string
> (so that should stop the process as "C:\ftp.log" no longer
> exists????)
> but it seems cumbersome, not to mention it doesn't work.
>
> How would I loop back through a process, terminating only if a certain
> string is found in a file that is re-downloaded every "X" number of
> minutes?
If this pseudo code does not help, post your code and explain what it does
and what should happen and where.

Do
If fso.FileExists("c:\ftp.log") Then
'Read file for "Yada-Yada"
If found Then
'.DeleteFile...
'download dataset
Exit Do
End If
Else
'File does not exist.
'Either keep looping or Exit Do
End If
Sleep xxx...
Loop

--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
escape character question - hopefully an easy question PowerShell
Workaround for using wildcard "*" with FileExists method VB Script
vista genral question and ultimate question Vista General
Dual boot system question and family deal discount question Vista General
OEM question Vista installation & setup


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46