Focal Point
SOLVED! alerts - testing for presence of a file

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/586109863

February 12, 2010, 10:35 AM
Mike in DeLand
SOLVED! alerts - testing for presence of a file
I'm trying to create an alert that will test to see if a file is present. However, I'm having trouble getting the alert to see the file. The documentation says to enter the full path of the file, which I suppose is
\\server\ibi\apps\baseapp\filename.txt. But when I place a file there, my DevStudio does not see it, and neither does the alert. The alert uses the STATE command, and I cannot find that documented anywhere. Thanks in advance.

This message has been edited. Last edited by: Mike in DeLand,


Webfocus 8
Windows, Linux
February 12, 2010, 10:51 AM
Ram Prasad E
Did you try -MRNOEDIT feature?


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 12, 2010, 11:16 AM
Mike in DeLand
I just tried that. I put -MRNOEDIT on the STATE line, but it did not help.

Here's the alert code:
  
-SET &ECHO=ALL;
APP SHOWPATH
-* Created by Alert Wizard
-* version 1.0
-* start of the test report
-* Restore State Command
-IF &FOCMODE EQ 'TSO' GOTO TSOSYS;
-IF &FOCMODE EQ 'MSO' GOTO TSOSYS;
-IF &FOCMODE EQ 'CRJE' GOTO TSOSYS;
-GOTO NOTTSO
-TSOSYS
? TSO DSNAME '\\hubappreports\ibi\WebFOCUS76\basedir\clerkofc\appmiketest.txt'
-IF &RETCODE NE 0 GOTO ALERTEXIT;
-GOTO AFTERFIL
-NOTTSO
-MRNOEDIT STATE \\hubappreports\ibi\apps\baseapp\miketest.txt
-* end of the test report
-* start of the test
-RUN
-IF &RETCODE NE 0 GOTO ALERTEXIT;
-AFTERFIL
-* end of the test
-* start of the output report
-* Description at creation time
-**get_facility
-INCLUDE app/get_facility.fex
-* end of the output report
-* start of the options
-* TWO_WAY_EMAIL=
-* TWO_WAY_EMAILDOMAIN=
-* TWO_WAY_EMAILDESCRIPTION=
-* TWO_WAY_EMAILFOLDER=
-* end of the options
-ALERTEXIT
-* End Alert Wizard



Webfocus 8
Windows, Linux
February 12, 2010, 11:38 AM
Dan Satchell
I believe the STATE command must be preceded by the operating system command (with exception of TSO).

DOS STATE \\hubappreports\ibi\apps\baseapp\miketest.txt



WebFOCUS 7.7.05
February 12, 2010, 11:47 AM
Mike in DeLand
Hi,

I just tried that too. Still no good. I'm getting a -1 return code. Can you tell I'm new at this? Red Face


Webfocus 8
Windows, Linux
February 12, 2010, 12:10 PM
Ram Prasad E
Using -MRNOEDIT, in case of multiple lines use the below syntax.

-mrnoedit begin

-**** code to be executed in reporting server

-mrnoedit end


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 12, 2010, 12:18 PM
Dan Satchell
Sorry Mike, the OS command begins with a dash (-DOS) because it is Dialogue Manager.

-DOS STATE \\hubappreports\ibi\apps\baseapp\miketest.txt



WebFOCUS 7.7.05
February 12, 2010, 12:28 PM
Ram Prasad E
In Developer Studio, only -DOS and -WINNT can be used.

DOS for DOS operating system.

WINNT for Windows operating system.


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 12, 2010, 01:10 PM
Mike in DeLand
ok, the -DOS STATE solved it! Thanks to everyone! I guess that's what I get for trusting the "wizard".


Webfocus 8
Windows, Linux
February 12, 2010, 02:11 PM
Mike in DeLand
Looks like I spoke too soon. After using the -DOS STATE, I got a good return code indicating that the file was present. However, after deleting the file I'm still getting the same 0 return code. I found this out by trying to do the delete using the -DOS DEL command in the procedure. It also came back with return code 0, but the file was still there. So, I manually deleted the file, and now the -DOS STATE command still thinks it's there. Frowner


Webfocus 8
Windows, Linux
February 12, 2010, 02:38 PM
GinnyJakes
This is not a fully formed idea but what about doing a -DOS DIR filename > output.dat. You could then -READ and parse what is in the file.
D:\ibi\apps\c758760>dir x* > output.dat
File Not Found

D:\ibi\apps\c758760>more output.dat
 Volume in drive D is Data
 Volume Serial Number is 1C97-CCC9

 Directory of D:\ibi\apps\c758760

If the file is not there, there are only 4 lines in the output file. If the file is there, there will be more lines. You would even be able to parse the line to extract the time stamp.

What do you think?


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
February 12, 2010, 03:14 PM
Mike in DeLand
I think it should work as documented, that's what I think. But I appreciate your tip. I'm new to this, so the redirection, reading the file, etc. will take me some time to figure out.


Webfocus 8
Windows, Linux
February 12, 2010, 04:44 PM
Dan Satchell
Mike, I agree that -DOS STATE should work. It also fails (with false positives) in my environment. It might be worth the trouble to open a case with IBI to see if they can sort it out. Here is another work-around to go with Ginny's suggestion. This assumes your file can always be found (when it exists) in an APP folder that is part of the APP path (baseapp in this example). APP QUERY creates a temporary list of all files from baseapp and also generates a master with the name FOCAPPQ. If the file exists &FILE_EXIST will have a value of 1; if not its value will be 0.

APP QUERY baseapp HOLD
-*
TABLEF FILE FOCAPPQ
 PRINT DATE
 WHERE FILENAME EQ 'miketest.txt';
 ON TABLE SAVE
END
-*
-RUN
-SET &FILE_EXIST = &LINES ;

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
February 12, 2010, 04:53 PM
Mike in DeLand
Thanks, Dan. I just now opened a case with IBI, but I'm also anxious to try your suggestion (on Monday - I'm out of here!)


Webfocus 8
Windows, Linux
February 12, 2010, 04:56 PM
GinnyJakes
Clever, Dan. I like it. Good One


Ginny
---------------------------------
Prod: WF 7.7.01 Dev: WF 7.6.9-11
Admin, MRE,self-service; adapters: Teradata, DB2, Oracle, SQL Server, Essbase, ESRI, FlexEnable, Google
February 12, 2010, 05:07 PM
Dan Satchell
I have to give credit to knegrotto for the idea. knegrotto's post entitled "Retrieving file object attributes" from Feb. 10th (link below) provides an excellent example of using APP QUERY.

http://forums.informationbuild...71057331/m/811100763

This message has been edited. Last edited by: Dan Satchell,


WebFOCUS 7.7.05
February 14, 2010, 09:08 AM
FrankDutch
great solution
thanks




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 15, 2010, 09:53 AM
<JG>
quote:
-DOS STATE \\hubappreports\ibi\apps\baseapp\miketest.txt

The correct way to use STATE is

DOS STATE absolute-filename or absolute-directory name

DOS STATE C:\Windows

is valid and retorns 0 if the directory exists and -1 if it does not exist

DOS STATE C:\Windows\twain_32.dll

is valid and retorns 0 if the file exists and -1 if it does not exist


However DOS STATE does not work with UNC naming

so

DOS STATE \\machinename\shared_folder_name\filename

is not valid
February 15, 2010, 10:34 AM
Mike in DeLand
Thanks for your response. I tried mapping a drive, then doing the STATE command pointing to my drive letter and folders. Still didn't work. I've got a remote session scheduled with IBI in about half an hour. I've got to be doing something wrong here.


Webfocus 8
Windows, Linux
February 15, 2010, 10:36 AM
GamP
What would happen if you did a net use first? Haven't tried this, but it might work. You would need to have a share on the remote machine somewhere along the path to the file you testing for. You then say something like NET USE Q: \\machine\named_share and follow this with the dos state q:\....\filename.txt
Did not test this, but it might work ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
February 15, 2010, 10:38 AM
GamP
Mike,
Our comments crossed each other.
Did you do the drive mapping using the net use command or just in the explorer?
If the latter, then your server will not see it, becaus eit will only see the drives mapped when you start the service.
If you do the net use in your fex, the server will see it.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
February 16, 2010, 10:45 AM
Mike in DeLand
quote:
Originally posted by Dan Satchell:
Mike, I agree that -DOS STATE should work. It also fails (with false positives) in my environment. It might be worth the trouble to open a case with IBI to see if they can sort it out. Here is another work-around to go with Ginny's suggestion. This assumes your file can always be found (when it exists) in an APP folder that is part of the APP path (baseapp in this example). APP QUERY creates a temporary list of all files from baseapp and also generates a master with the name FOCAPPQ. If the file exists &FILE_EXIST will have a value of 1; if not its value will be 0.

APP QUERY baseapp HOLD
-*
TABLEF FILE FOCAPPQ
 PRINT DATE
 WHERE FILENAME EQ 'miketest.txt';
 ON TABLE SAVE
END
-*
-RUN
-SET &FILE_EXIST = &LINES ;


Dan, this solved the problem! It turns out that due to our overly-complex installation and environment, that I was not even looking in the right place for the file. Once we got that sorted out, I worked with IBI on the STATE command that the Alert Wizard created (which still does not work). So, today I tried your solution with success. Thanks.


Webfocus 8
Windows, Linux