[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: [sqr-users] check datetime stamp on file
- Subject: Re: [sqr-users] check datetime stamp on file
- From: "George Jansen" <GJANSEN@aflcio.org>
- Date: Mon, 30 Aug 2004 16:41:26 -0400
- Delivery-date: Mon, 30 Aug 2004 15:44:27 -0500
- List-id: "This list is for discussion about the SQR database reportinglanguage from Hyperion Solutions." <sqr-users.sqrug.org>
A clarification. The find, on Solaris gives an ok (0) status. What you
have to do is use a bit of shell scripting to convert the blank or
non-blank string returned by find into a numeric value for SQR:
***************************
/tmp>cat newold.ksh
#!/bin/ksh
x=`find /var/adm -name $1 -mtime -1`
if [ -n "$x" ]
then
exit 0
else
exit 1
fi
/tmp>cat newold.sqr
begin-program
input $filename 'filename:'
let $systring = 'newold.ksh ' || $filename
call system using $systring #status
display $filename noline
if #status = 0
display ' is new '
else
display ' does not exist or is old'
end-if
*****************************************************
Then you can run it:
/tmp>sqr newold / -XL messages
SQR V4.3.2.2
Copyright (C) SQRIBE Technologies, 1994-98. All Worldwide Rights
Reserved.
messages is new
SQR: End of Run.
/tmp>sqr newold / -XL messages.3
SQR V4.3.2.2
Copyright (C) SQRIBE Technologies, 1994-98. All Worldwide Rights
Reserved.
messages.3 does not exist or is old
SQR: End of Run.
>>> lakef250@yahoo.com 08/30/04 04:27PM >>>
Thanks, George. Just the ticket!
George Jansen <GJANSEN@aflcio.org> wrote:on Unix,
find /whiz -name bang -mtime -1
will return a 0 if /whiz/bang exists and has been modified in the last
24 hours, non-zero otherwise.
On NT I suppose you could use a fragment of VBScript that would raise
an error if the file did not exist.
>>> JHarris@frederick.edu 08/30/04 12:33PM >>>
To see if the file exists, simply try to open it for reading - if it
does not exist you will get an error code.
open $filename as 6 for-reading record=132:vary status=#filestat
In this case, the #filestat variable would end up with 0 or -1
depending on the success. 0 means the file is there and readable, -1
means something prevents you from opening it for reading (file
permissions and even file locking could also cause such a failure).
Getting the date/time isn't as easy.
One way would be to call system and perform a directory listing of the
file you want to check, and parse it. Of course that's very messy
and
platform specific.
-----------------------------------------------------
James Harris
Junior Systems Programmer/Analyst
Information Technology Division
Frederick Community College
-----------------------------------------------------
>>> lakef250@yahoo.com 8/30/2004 11:05:17 AM >>>
RESEND:
Anyone know how to determine datetime of a file programmatically?
Yuri Lakef wrote:Greetings to all,
I'd like to add a procedure in my SQR to call the operating system and
check if a file exists or not (SQR reads a file and loads a table). If
it does exist, I'd like to check the datetime stamp for the file and
only process if it matches "today's date."
Are there operating system (or better yet, SQR) functions/features
that
allow this? We're on Unix AIX and NT.
Much thanks!
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
---------------------------------
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users
_______________________________________________
sqr-users mailing list
sqr-users@sqrug.org
http://www.sqrug.org/mailman/listinfo/sqr-users