- AZHQUNIX ;IHS/OIRM/AEF - READ UNIX FILE [ 12/17/2001 9:58 AM ]
- ;;1.0t1;AEF UTILITY ROUTINES
- ;;
- ;;
- ;;THIS ROUTINE CONTAINS ENTRY POINTS TO READ UNIX FILE CONTENTS
- ;;
- ;;****THIS ROUTINE IS UNDER CONSTRUCTION****
- ;;
- READ(PATH,FILE) ;EP
- ;----- READS CONTENTS OF UNIX FILE
- ;
- ; RETURNS CONTENTS OF UNIX FILE IN ^TMP("AZHQ",$J,"UNIX",IEN,0)
- ;
- ; PATH = DIRECTORY CONTAINING UNIX FILE
- ; EXAMPLE: /usr3/dsd/afugatt/
- ; FILE = UNIX FILE
- ; EXAMPLE: dhr4.dat
- ; HFS = HOST FILE SERVER
- ; OUT = QUIT CONTROLLER
- ; AZHQERR = ARRAY CONTAINING FAILURE MESSAGES
- ;
- ;N OUT,HFS,I,X
- D ^XBKVAR
- K ^TMP("AZHQ",$J,"UNIX")
- S OUT=0
- D OPEN^%ZISH("FILE",PATH,FILE,"R")
- I POP D Q
- . W "UNABLE TO OPEN FILE '"_FILE_"'"
- U IO
- F I=1:1 D Q:OUT
- . R X:DTIME
- . I $$STATUS^%ZISH S OUT=1 Q
- . F J="":1:31 S X=$TR(X,$C(J)) ; REMOVE ALL CONTROL CHARACTERS
- . S ^TMP("AZHQ",$J,"UNIX",I,0)=X
- . S ^TMP("AZHQ",$J,"UNIX",0)=$G(^TMP("AZHQ",$J,"UNIX",0))+1
- D CLOSE^%ZISH("FILE")
- Q
- SELD ;EP -- SELECT UNIX PATH OR DIRECTORY
- ;
- ; RETURNS AZHQPATH = UNIX DIRECTORY
- ; OUT = 1 IF UNSUCCESSFUL
- ;
- N DIR,OUT,X,Y
- D ^XBKVAR
- S AZHQPATH="",OUT=0
- S DIR(0)="FA",DIR("A")="Select UNIX Directory: "
- S DIR("?")="Enter the PATH or DIRECTORY where the UNIX file resides, e.g., /usr3/dsd/afugatt/"
- F D Q:OUT
- . D ^DIR
- . I $D(DIRUT)!($D(DUOUT))!($D(DTOUT)) S OUT=1 Q
- . I $E(Y)'="/" W !,"Directory must begin with '/'" Q
- . I $$CHKPATH^AZHQUNIX(Y) W !,"No such directory '"_Y_"'" Q
- . S AZHQPATH=Y,OUT=1
- Q:AZHQPATH']""
- S AZHQPATH=$TR(AZHQPATH,"\""""'* ","")
- I $E(AZHQPATH,$L(AZHQPATH))'="/" S AZHQPATH=AZHQPATH_"/"
- Q
- SELF(PATH) ;EP
- ;----- SELECT UNIX FILE
- ;
- ; RETURNS AZHQFILE = UNIX FILE
- ; OUT = 1 IF UNSUCCESSFUL
- ;
- ; PATH = PATH OR DIRECTORY CONTAINING THE FILE
- ;
- N DIR,OUT,X,Y
- D ^XBKVAR
- I PATH']"" W !,"No UNIX directory has been specified" Q
- I $$CHKPATH^AZHQUNIX(PATH) W !,"No such directory '"_PATH_"'" Q
- S AZHQFILE="",OUT=0
- S DIR(0)="FA",DIR("A")="Select UNIX File: "
- S DIR("?")="^D HELP1^AZHQUNIX(PATH)"
- F D Q:OUT
- . D ^DIR
- . I $D(DIRUT)!($D(DUOUT))!($D(DTOUT)) S OUT=1 Q
- . I $E(Y)="/" S Y=$P(Y,"/",2)
- . S X=$$OPEN^%ZISH(PATH,Y,"R")
- . I 'X S AZHQFILE=Y,OUT=1 Q
- . W !,"Unable to open file ",Y
- Q
- HELP1(PATH) ;
- ;----- HELP FOR UNIX FILE SELECTION
- ;
- ; PATH = UNIX DIRECTORY WHERE THE FILE RESIDES
- ;
- N X
- I PATH']"" W !,"No directory has been specified" Q
- I $$CHKPATH^AZHQUNIX(PATH) W !,"No such directory '"_PATH_"'" Q
- W !,"DIRECTORY: ",PATH,!
- S X=$$JOBWAIT^%HOSTCMD("cd "_PATH)
- S X=$$TERMINAL^%HOSTCMD("ls -p -l | grep -v ""/""")
- Q
- CHKPATH(PATH) ;
- ;----- CHECKS FOR VALID UNIX PATH
- ;
- ; RETURNS 0 IF VALID, 1 IF NOT VALID
- ; PATH = UNIX DIRECTORY
- ;
- N X
- S X=$$JOBWAIT^%HOSTCMD("cd "_PATH)
- Q X
-
- AZHQUNIX ;IHS/OIRM/AEF - READ UNIX FILE [ 12/17/2001 9:58 AM ]
- +1 ;;1.0t1;AEF UTILITY ROUTINES
- +2 ;;
- +3 ;;
- +4 ;;THIS ROUTINE CONTAINS ENTRY POINTS TO READ UNIX FILE CONTENTS
- +5 ;;
- +6 ;;****THIS ROUTINE IS UNDER CONSTRUCTION****
- +7 ;;
- READ(PATH,FILE) ;EP
- +1 ;----- READS CONTENTS OF UNIX FILE
- +2 ;
- +3 ; RETURNS CONTENTS OF UNIX FILE IN ^TMP("AZHQ",$J,"UNIX",IEN,0)
- +4 ;
- +5 ; PATH = DIRECTORY CONTAINING UNIX FILE
- +6 ; EXAMPLE: /usr3/dsd/afugatt/
- +7 ; FILE = UNIX FILE
- +8 ; EXAMPLE: dhr4.dat
- +9 ; HFS = HOST FILE SERVER
- +10 ; OUT = QUIT CONTROLLER
- +11 ; AZHQERR = ARRAY CONTAINING FAILURE MESSAGES
- +12 ;
- +13 ;N OUT,HFS,I,X
- +14 DO ^XBKVAR
- +15 KILL ^TMP("AZHQ",$JOB,"UNIX")
- +16 SET OUT=0
- +17 DO OPEN^%ZISH("FILE",PATH,FILE,"R")
- +18 IF POP
- Begin DoDot:1
- +19 WRITE "UNABLE TO OPEN FILE '"_FILE_"'"
- End DoDot:1
- QUIT
- +20 USE IO
- +21 FOR I=1:1
- Begin DoDot:1
- +22 READ X:DTIME
- +23 IF $$STATUS^%ZISH
- SET OUT=1
- QUIT
- +24 ; REMOVE ALL CONTROL CHARACTERS
- FOR J="":1:31
- SET X=$TRANSLATE(X,$CHAR(J))
- +25 SET ^TMP("AZHQ",$JOB,"UNIX",I,0)=X
- +26 SET ^TMP("AZHQ",$JOB,"UNIX",0)=$GET(^TMP("AZHQ",$JOB,"UNIX",0))+1
- End DoDot:1
- IF OUT
- QUIT
- +27 DO CLOSE^%ZISH("FILE")
- +28 QUIT
- SELD ;EP -- SELECT UNIX PATH OR DIRECTORY
- +1 ;
- +2 ; RETURNS AZHQPATH = UNIX DIRECTORY
- +3 ; OUT = 1 IF UNSUCCESSFUL
- +4 ;
- +5 NEW DIR,OUT,X,Y
- +6 DO ^XBKVAR
- +7 SET AZHQPATH=""
- SET OUT=0
- +8 SET DIR(0)="FA"
- SET DIR("A")="Select UNIX Directory: "
- +9 SET DIR("?")="Enter the PATH or DIRECTORY where the UNIX file resides, e.g., /usr3/dsd/afugatt/"
- +10 FOR
- Begin DoDot:1
- +11 DO ^DIR
- +12 IF $DATA(DIRUT)!($DATA(DUOUT))!($DATA(DTOUT))
- SET OUT=1
- QUIT
- +13 IF $EXTRACT(Y)'="/"
- WRITE !,"Directory must begin with '/'"
- QUIT
- +14 IF $$CHKPATH^AZHQUNIX(Y)
- WRITE !,"No such directory '"_Y_"'"
- QUIT
- +15 SET AZHQPATH=Y
- SET OUT=1
- End DoDot:1
- IF OUT
- QUIT
- +16 IF AZHQPATH']""
- QUIT
- +17 SET AZHQPATH=$TRANSLATE(AZHQPATH,"\""""'* ","")
- +18 IF $EXTRACT(AZHQPATH,$LENGTH(AZHQPATH))'="/"
- SET AZHQPATH=AZHQPATH_"/"
- +19 QUIT
- SELF(PATH) ;EP
- +1 ;----- SELECT UNIX FILE
- +2 ;
- +3 ; RETURNS AZHQFILE = UNIX FILE
- +4 ; OUT = 1 IF UNSUCCESSFUL
- +5 ;
- +6 ; PATH = PATH OR DIRECTORY CONTAINING THE FILE
- +7 ;
- +8 NEW DIR,OUT,X,Y
- +9 DO ^XBKVAR
- +10 IF PATH']""
- WRITE !,"No UNIX directory has been specified"
- QUIT
- +11 IF $$CHKPATH^AZHQUNIX(PATH)
- WRITE !,"No such directory '"_PATH_"'"
- QUIT
- +12 SET AZHQFILE=""
- SET OUT=0
- +13 SET DIR(0)="FA"
- SET DIR("A")="Select UNIX File: "
- +14 SET DIR("?")="^D HELP1^AZHQUNIX(PATH)"
- +15 FOR
- Begin DoDot:1
- +16 DO ^DIR
- +17 IF $DATA(DIRUT)!($DATA(DUOUT))!($DATA(DTOUT))
- SET OUT=1
- QUIT
- +18 IF $EXTRACT(Y)="/"
- SET Y=$PIECE(Y,"/",2)
- +19 SET X=$$OPEN^%ZISH(PATH,Y,"R")
- +20 IF 'X
- SET AZHQFILE=Y
- SET OUT=1
- QUIT
- +21 WRITE !,"Unable to open file ",Y
- End DoDot:1
- IF OUT
- QUIT
- +22 QUIT
- HELP1(PATH) ;
- +1 ;----- HELP FOR UNIX FILE SELECTION
- +2 ;
- +3 ; PATH = UNIX DIRECTORY WHERE THE FILE RESIDES
- +4 ;
- +5 NEW X
- +6 IF PATH']""
- WRITE !,"No directory has been specified"
- QUIT
- +7 IF $$CHKPATH^AZHQUNIX(PATH)
- WRITE !,"No such directory '"_PATH_"'"
- QUIT
- +8 WRITE !,"DIRECTORY: ",PATH,!
- +9 SET X=$$JOBWAIT^%HOSTCMD("cd "_PATH)
- +10 SET X=$$TERMINAL^%HOSTCMD("ls -p -l | grep -v ""/""")
- +11 QUIT
- CHKPATH(PATH) ;
- +1 ;----- CHECKS FOR VALID UNIX PATH
- +2 ;
- +3 ; RETURNS 0 IF VALID, 1 IF NOT VALID
- +4 ; PATH = UNIX DIRECTORY
- +5 ;
- +6 NEW X
- +7 SET X=$$JOBWAIT^%HOSTCMD("cd "_PATH)
- +8 QUIT X
- +9
- ***** ERRORS & WARNINGS IN AZHQUNIX *****
- AZHQUNIX+1 S - 2nd line of routine violates the SAC.
- CHKPATH+9 W - Null line (no commands or comment).