Re: [U2] test for a unix file?
If all the files are in the same directory, use OPENPATH to open the directory into a common variable (if it's not already open), then use READV with 0 as the field number. FUNCTION DOODLE(DIRPATH,FILENAME) COMMON /DOODLE/FILEVAR IF FILEINFO(FILEVAR,0) ELSE OPENPATH (DIRPATH) TO FILEVAR ELSE FILEVAR = 0 END READV TEST FROM FILEVAR,(FILENAME),0 THEN RETURN(Yes) ELSE RETURN(No) END --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] test for a unix file?
I use DIR() Function. Thanks, David A. Green www.dagconsulting.com (480) 813-1725 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Ballinger Sent: Monday, March 03, 2008 6:28 PM To: u2-users@listserver.u2ug.org Subject: [U2] test for a unix file? I have a standard subroutine that I use in UV BASIC when I need to check for the existence (or non-existance) of a unix file: FILE.TEST.SUB 0001 SUB(FILENAME,ANS) 0002 * return ans = 1 if filename exists 0003 * redirect to bit bucket to suppress 'not on file' msg 0004 * filename includes full path to file 0005 EXECUTE SH -c 'ls -d :FILENAME: 2 /dev/null' CAPTURING XXX 0006 0007 FN = FILENAME 0008 CONVERT \ TO IN FN ;* in case we escaped any special characters 0009 0010 IF XXX1 EQ FN THEN ANS = 1 ELSE ANS = 0 0011 0012 RETURN 0013 It works fine, but seems pretty slow, particularly if I am churning though thousands of tests (like from a big select list). Can anyone suggest a faster/more efficient way to test if a unix level file exists from inside UV BASIC ? Thanks, /Scott Ballinger Pareto Corporation Edmonds WA USA 206 713 6006 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] test for a unix file?
Thanks all; test -e (for files) or test -d (for directories) seems to be what I was looking for. What is DIR() ? I don't find it in HELP BASIC DIR and it won't compile (no matter how I use it I get array DIR never dimensioned). /Scott On Tue, Mar 4, 2008 at 6:33 AM, David A. Green [EMAIL PROTECTED] wrote: I use DIR() Function. Thanks, David A. Green www.dagconsulting.com (480) 813-1725 -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Ballinger Sent: Monday, March 03, 2008 6:28 PM To: u2-users@listserver.u2ug.org Subject: [U2] test for a unix file? I have a standard subroutine that I use in UV BASIC when I need to check for the existence (or non-existance) of a unix file: FILE.TEST.SUB 0001 SUB(FILENAME,ANS) 0002 * return ans = 1 if filename exists 0003 * redirect to bit bucket to suppress 'not on file' msg 0004 * filename includes full path to file 0005 EXECUTE SH -c 'ls -d :FILENAME: 2 /dev/null' CAPTURING XXX 0006 0007 FN = FILENAME 0008 CONVERT \ TO IN FN ;* in case we escaped any special characters 0009 0010 IF XXX1 EQ FN THEN ANS = 1 ELSE ANS = 0 0011 0012 RETURN 0013 It works fine, but seems pretty slow, particularly if I am churning though thousands of tests (like from a big select list). Can anyone suggest a faster/more efficient way to test if a unix level file exists from inside UV BASIC ? Thanks, /Scott Ballinger Pareto Corporation Edmonds WA USA 206 713 6006 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] test for a unix file?
Scott: DIR() is a UniData BASIC command to get the size and date/time modified info from an O/S level file or directory . Bill -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Ballinger Sent: Tuesday, March 04, 2008 8:28 AM To: u2-users@listserver.u2ug.org Subject: Re: [U2] test for a unix file? Thanks all; test -e (for files) or test -d (for directories) seems to be what I was looking for. What is DIR() ? I don't find it in HELP BASIC DIR and it won't compile (no matter how I use it I get array DIR never dimensioned). /Scott On Tue, Mar 4, 2008 at 6:33 AM, David A. Green [EMAIL PROTECTED] wrote: I use DIR() Function. Thanks, David A. Green www.dagconsulting.com (480) 813-1725 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] test for a unix file?
From the below statement I think Scot is using universe and I don't think DIR is available in UV I have a standard subroutine that I use in *UV* BASIC dougc Bill Haskett wrote: Scott: DIR() is a UniData BASIC command to get the size and date/time modified info from an O/S level file or directory . Bill -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Scott Ballinger Sent: Tuesday, March 04, 2008 8:28 AM To: u2-users@listserver.u2ug.org Subject: Re: [U2] test for a unix file? Thanks all; test -e (for files) or test -d (for directories) seems to be what I was looking for. What is DIR() ? I don't find it in HELP BASIC DIR and it won't compile (no matter how I use it I get array DIR never dimensioned). /Scott On Tue, Mar 4, 2008 at 6:33 AM, David A. Green [EMAIL PROTECTED] wrote: I use DIR() Function. Thanks, David A. Green www.dagconsulting.com (480) 813-1725 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] test for a unix file?
Hi Scott, how about OPENSEQ? or if the files are in your local account (and are not subdirectories) OPEN UFD TO UFD ELSE STOP READV EXISTS FROM UFD, FILENAME, 0 ON ERROR ANS = @FALSE END THEN ANS = @TRUE ELSE ANS = @FALSE END HTH, Craig Scott Ballinger wrote: I have a standard subroutine that I use in UV BASIC when I need to check for the existence (or non-existance) of a unix file: FILE.TEST.SUB 0001 SUB(FILENAME,ANS) 0002 * return ans = 1 if filename exists 0003 * redirect to bit bucket to suppress 'not on file' msg 0004 * filename includes full path to file 0005 EXECUTE SH -c 'ls -d :FILENAME: 2 /dev/null' CAPTURING XXX 0006 0007 FN = FILENAME 0008 CONVERT \ TO IN FN ;* in case we escaped any special characters 0009 0010 IF XXX1 EQ FN THEN ANS = 1 ELSE ANS = 0 0011 0012 RETURN 0013 It works fine, but seems pretty slow, particularly if I am churning though thousands of tests (like from a big select list). Can anyone suggest a faster/more efficient way to test if a unix level file exists from inside UV BASIC ? Thanks, /Scott Ballinger Pareto Corporation Edmonds WA USA 206 713 6006 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ -- Craig Bennett Director Amajuba Pty Ltd Phone: 02 9987 0161 Mobile: 0412448781 Fax: 02 8456 5943 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
Re: [U2] test for a unix file?
I have not had time to test this with lots of files BUT you can try it (I think it will be much faster than what your doing in your code BUT I may be wrong) anyway what I did was create a simple shell script that you call with a FULLY pathed file name (unless you are in the directory that you want to check) and it will return a 1 if it exists or a 0 if it does not Below is the shell script *#!/usr/bin/ksh if (test -e $1) then echo '1' else echo '0' fi* *exit end shell script and below is a sample run $ ./testit ./testit1 == this file does NOT exist 0 $ ./testit ./testit == this file DOES exist 1 now all you have to in your basic code is CMD = 'sh -c testit ':FILE.TO.TEST:'' EXECUTE CMD CAPTURING RESULTS one thing you may have to do is remove any unix line feeds before you compare the results, if RESULTS = 1 does not match and you know the file exists IF RESULTS = 1 THEN PRINT 'file exists ' END ELSE PRINT ' file does not exist s' END well you get the idea, I think it will be much faster hope that helps dougc * ps you may have to modify the first line of the shell script if your ksh is in a different location (which ksh will tell you where its located) Scott Ballinger wrote: I have a standard subroutine that I use in UV BASIC when I need to check for the existence (or non-existance) of a unix file: FILE.TEST.SUB 0001 SUB(FILENAME,ANS) 0002 * return ans = 1 if filename exists 0003 * redirect to bit bucket to suppress 'not on file' msg 0004 * filename includes full path to file 0005 EXECUTE SH -c 'ls -d :FILENAME: 2 /dev/null' CAPTURING XXX 0006 0007 FN = FILENAME 0008 CONVERT \ TO IN FN ;* in case we escaped any special characters 0009 0010 IF XXX1 EQ FN THEN ANS = 1 ELSE ANS = 0 0011 0012 RETURN 0013 It works fine, but seems pretty slow, particularly if I am churning though thousands of tests (like from a big select list). Can anyone suggest a faster/more efficient way to test if a unix level file exists from inside UV BASIC ? Thanks, /Scott Ballinger Pareto Corporation Edmonds WA USA 206 713 6006 --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/
RE: [U2] test for a unix file?
Scott, Change your Unix command to:- EXECUTE SH -c 'test -e :FILENAME: echo yes || echo no' CAPTURING XXX XXX will contain yes or no depending on whether the file exists. That is subject to your access to the file and it parent folder tree. So no could mean that the file cannot be seen by you. This will be faster than using ls. Jeffrey Lee Senior Analyst/Programmer IT Vision Australia Pty Ltd (ABN: 34 309 336 904) PO Box 881, Canning Bridge WA 6153 Level 3, Kirin Centre, 15 Ogilvie Road, Applecross, WA, 6153 P: (08) 9315 7000F: (08) 9315 7088 W: http://www.itvision.com.au ___ NOTICE : This e-mail and any attachments are intended for the addressee(s) only and may contain confidential or privileged material. Any unauthorised review, use, alteration, disclosure or distribution of this e-mail (including any attachments) by an unintended recipient is prohibited. If you are not the intended recipient please contact the sender as soon as possible by return e-mail and then delete both messages. ___ --- u2-users mailing list u2-users@listserver.u2ug.org To unsubscribe please visit http://listserver.u2ug.org/