Can Wait for file Activity use Wildcards?

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
tracy
Participant
Posts: 47
Joined: Mon Aug 07, 2006 9:19 am

Can Wait for file Activity use Wildcards?

Post by tracy »

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?
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Welcome Aboard!

It is not possible to use wildcard characters while using the Wait_For_File_Activity stage
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
tracy
Participant
Posts: 47
Joined: Mon Aug 07, 2006 9:19 am

Post by tracy »

Thanks! Then I will stop trying to get it to do it.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Can you mark it as resolved :roll:
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Perhaps somone should actually post a resolution first? What would you suggest as an alternative? I'd hate to see Tracy's first foray into DSXchange end with what basically amounts to a one word answer - 'nope'. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.

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.
Post Reply