I want to wait for the appearance or disappearance of any file with a certain extension.
So I tried to put something like:
*.txt
in the filename box, but it doesn't work. It looks like it's looking for a filename that has an asterick-period-t-x-t as opposed to anything that ends with .txt.
Is there a different wildcard character? Or is this not possible?
Can Wait for file Activity use Wildcards?
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Well, not trying to do something that won't work is a resolution of a kind.
The usual solution to this is to create your own routine. Something like this one.
The usual solution to this is to create your own routine. Something like this one.
Code: Select all
FUNCTION WaitForFile(WildCard, TimeOut)
* Returns 0 if there is at least one file that matches WildCard,
* returns 1 if the timeout (given in seconds) expires.
* Ray Wurlod, 01 Dec 2006.
Equate RoutineName To "WaitForFile"
Equate DELAY To 5 ; * time to wait between checks
$DEFINE LOGGING
* Set up for operating system
If System(91) = 0
Then
Shell = "UNIX"
Command = "ls -1 " : WildCard
End
Else
Shell = "DOS"
Command = "dir " : WildCard
End
* We rely on the fact that "not found" will set exit status to a non-zero value.
* This is $? in UNIX and %ERRORLEVEL% in DOS, but is captured automatically for us by DSExecute.
Timer = 0
Loop
Call DSExecute(Shell, Command, Output, ExitStatus)
While ExitStatus <> 0 And Timer < TimeOut
Timer += DELAY
Sleep DELAY
Repeat
Ans = Not(Not(ExitStatus))
$IFDEF LOGGING
If ExitStatus() <> 0
Then
* Decompose wildcard into directory and entryname components
Call !GET.PATHNAME(WildCard, DirPath, EntryName, StatusCode)
Message = "No file matching " : Quote(EntryName) : " found in " : Quote(DirPath) : "."
Call DSLogWarn(Message, RoutineName)
End
$ENDIF
RETURN(Ans)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.