Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: AZHQUNIX

AZHQUNIX.m

Go to the documentation of this file.
  1. AZHQUNIX ;IHS/OIRM/AEF - READ UNIX FILE [ 12/17/2001 9:58 AM ]
  1. ;;1.0t1;AEF UTILITY ROUTINES
  1. ;;
  1. ;;
  1. ;;THIS ROUTINE CONTAINS ENTRY POINTS TO READ UNIX FILE CONTENTS
  1. ;;
  1. ;;****THIS ROUTINE IS UNDER CONSTRUCTION****
  1. ;;
  1. READ(PATH,FILE) ;EP
  1. ;----- READS CONTENTS OF UNIX FILE
  1. ;
  1. ; RETURNS CONTENTS OF UNIX FILE IN ^TMP("AZHQ",$J,"UNIX",IEN,0)
  1. ;
  1. ; PATH = DIRECTORY CONTAINING UNIX FILE
  1. ; EXAMPLE: /usr3/dsd/afugatt/
  1. ; FILE = UNIX FILE
  1. ; EXAMPLE: dhr4.dat
  1. ; HFS = HOST FILE SERVER
  1. ; OUT = QUIT CONTROLLER
  1. ; AZHQERR = ARRAY CONTAINING FAILURE MESSAGES
  1. ;
  1. ;N OUT,HFS,I,X
  1. D ^XBKVAR
  1. K ^TMP("AZHQ",$J,"UNIX")
  1. S OUT=0
  1. D OPEN^%ZISH("FILE",PATH,FILE,"R")
  1. I POP D Q
  1. . W "UNABLE TO OPEN FILE '"_FILE_"'"
  1. U IO
  1. F I=1:1 D Q:OUT
  1. . R X:DTIME
  1. . I $$STATUS^%ZISH S OUT=1 Q
  1. . F J="":1:31 S X=$TR(X,$C(J)) ; REMOVE ALL CONTROL CHARACTERS
  1. . S ^TMP("AZHQ",$J,"UNIX",I,0)=X
  1. . S ^TMP("AZHQ",$J,"UNIX",0)=$G(^TMP("AZHQ",$J,"UNIX",0))+1
  1. D CLOSE^%ZISH("FILE")
  1. Q
  1. SELD ;EP -- SELECT UNIX PATH OR DIRECTORY
  1. ;
  1. ; RETURNS AZHQPATH = UNIX DIRECTORY
  1. ; OUT = 1 IF UNSUCCESSFUL
  1. ;
  1. N DIR,OUT,X,Y
  1. D ^XBKVAR
  1. S AZHQPATH="",OUT=0
  1. S DIR(0)="FA",DIR("A")="Select UNIX Directory: "
  1. S DIR("?")="Enter the PATH or DIRECTORY where the UNIX file resides, e.g., /usr3/dsd/afugatt/"
  1. F D Q:OUT
  1. . D ^DIR
  1. . I $D(DIRUT)!($D(DUOUT))!($D(DTOUT)) S OUT=1 Q
  1. . I $E(Y)'="/" W !,"Directory must begin with '/'" Q
  1. . I $$CHKPATH^AZHQUNIX(Y) W !,"No such directory '"_Y_"'" Q
  1. . S AZHQPATH=Y,OUT=1
  1. Q:AZHQPATH']""
  1. S AZHQPATH=$TR(AZHQPATH,"\""""'* ","")
  1. I $E(AZHQPATH,$L(AZHQPATH))'="/" S AZHQPATH=AZHQPATH_"/"
  1. Q
  1. SELF(PATH) ;EP
  1. ;----- SELECT UNIX FILE
  1. ;
  1. ; RETURNS AZHQFILE = UNIX FILE
  1. ; OUT = 1 IF UNSUCCESSFUL
  1. ;
  1. ; PATH = PATH OR DIRECTORY CONTAINING THE FILE
  1. ;
  1. N DIR,OUT,X,Y
  1. D ^XBKVAR
  1. I PATH']"" W !,"No UNIX directory has been specified" Q
  1. I $$CHKPATH^AZHQUNIX(PATH) W !,"No such directory '"_PATH_"'" Q
  1. S AZHQFILE="",OUT=0
  1. S DIR(0)="FA",DIR("A")="Select UNIX File: "
  1. S DIR("?")="^D HELP1^AZHQUNIX(PATH)"
  1. F D Q:OUT
  1. . D ^DIR
  1. . I $D(DIRUT)!($D(DUOUT))!($D(DTOUT)) S OUT=1 Q
  1. . I $E(Y)="/" S Y=$P(Y,"/",2)
  1. . S X=$$OPEN^%ZISH(PATH,Y,"R")
  1. . I 'X S AZHQFILE=Y,OUT=1 Q
  1. . W !,"Unable to open file ",Y
  1. Q
  1. HELP1(PATH) ;
  1. ;----- HELP FOR UNIX FILE SELECTION
  1. ;
  1. ; PATH = UNIX DIRECTORY WHERE THE FILE RESIDES
  1. ;
  1. N X
  1. I PATH']"" W !,"No directory has been specified" Q
  1. I $$CHKPATH^AZHQUNIX(PATH) W !,"No such directory '"_PATH_"'" Q
  1. W !,"DIRECTORY: ",PATH,!
  1. S X=$$JOBWAIT^%HOSTCMD("cd "_PATH)
  1. S X=$$TERMINAL^%HOSTCMD("ls -p -l | grep -v ""/""")
  1. Q
  1. CHKPATH(PATH) ;
  1. ;----- CHECKS FOR VALID UNIX PATH
  1. ;
  1. ; RETURNS 0 IF VALID, 1 IF NOT VALID
  1. ; PATH = UNIX DIRECTORY
  1. ;
  1. N X
  1. S X=$$JOBWAIT^%HOSTCMD("cd "_PATH)
  1. Q X