Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!rutgers!sri-spam!ames!ucbcad!zen!ucbvax!UHHEPG.BITNET!RALPH From: RALPH@UHHEPG.BITNET Newsgroups: comp.os.vms Subject: Command input from a file continued, and maybe a bug in VMS Message-ID: <8708071731.AA11054@ucbvax.Berkeley.EDU> Date: Fri, 7-Aug-87 13:32:05 EDT Article-I.D.: ucbvax.8708071731.AA11054 Posted: Fri Aug 7 13:32:05 1987 Date-Received: Sun, 9-Aug-87 03:29:11 EDT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 77 Date: 5-AUG-1987 20:29:29.00 From: Ralph Becker-Szendy RALPH AT UHHEPG To: B_INFOVAX,RALPH Subj: Command input from a file continued, and maybe a bug in VMS Hi everyone out there Thanks a lot for all the help i got for my little problem with input/output redirection: > I want something like the DCL @ command: If the command is @filespec, > the command interpreters should open this file, and present it (line > by line) to CLI$DCL_PARSE and other routines, which read special input > from a terminal. Unfortunately, none of the help got me anywhere (or rather: some of them seem to get me into bug-land). I was offered really big packages for this purpose (mostly written in straight FORTRAN), but they are bulky, and would require a lot of recoding (since they would completely replace all the CLI$... routines), and a lot of understanding them , and i wanted a quick afternoon-hack. Several fellow netpeople pointed mo towards the LIB$SET_LOGICAL routine, which seems to do what i want: assign SYS$INPUT or SYS$OUTPUT to a file (instead of the terminal) for a while while the programs runs. Unfortunately, i found some quite strange behaviour. Look at the following short FORTRAN program. It should read one line from the terminal, print it, and then redirect SYS$INPUT to the file INPUT.FILE, read one line from there, print it, and exit: PROGRAM MINITEST ! mini version without loops or error handling IMPLICIT NONE CHARACTER INPUT*80 INTEGER LENGTH, STATUS INTEGER LIB$GET_INPUT, LIB$SET_LOGICAL EXTERNAL LIB$GET_INPUT, LIB$SET_LOGICAL INCLUDE '($RMSDEF)' ! not yet needed, for recognizing EOFs later STATUS = LIB$GET_INPUT(INPUT, 'From Terminal: ', LENGTH) IF (.NOT.STATUS) CALL LIB$SIGNAL(%VAL(STATUS)) PRINT *, 'Input from terminal was ', INPUT(1:LENGTH) STATUS = LIB$SET_LOGICAL('SYS$INPUT', 'INPUT.FILE') IF (.NOT.STATUS) CALL LIB$SIGNAL(%VAL(STATUS)) STATUS = LIB$GET_INPUT(INPUT, 'From File: ', LENGTH) IF (.NOT.STATUS) CALL LIB$SIGNAL(%VAL(STATUS)) PRINT *, 'Input from file was ', INPUT(1:LENGTH) STOP END Well, it does the following: - it reads one line from the terminal and prints it - it does reassign SYS$INPUT to INPUT.FILE (you can check it by inserting a call to LIB$SYS_TRNLOG('SYS$INPUT'... after the assign) - it reads ANOTHER LINE FROM THE TERMINAL and prints it ! - Now, back at DCL, a SHOW TRANS SYS$INPUT will yield INPUT.FILE (obviously), so i try running the program again: - it reads the first line from the file (obviously) and prints it - it reads the second line from the file (still obvious) and prints it. All variations of the program (like read many lines instead of one, check for EOFs and such, which i ommited here for the sake of brevity) seem completely consistent: what counts for LIB$INPUT is not the translation of SYS$INPUT at the time you call it, but AT THE TIME THE PROGRAM WAS INVOKED. If SYS$INPUT points to the terminal at the beginning of the program, all the LIB$SET_LOGICALS can't change the mind of LIB$GET_INPUT. The only question it: why is this so ? What use is LIB$SET_LOGICAL in this case ? Is this a bug ? Should i SPR it ? Am i stupid ? Is there something tricky (maybe using the right logical name table) i overlooked ? signed: confused Ralph Becker-Szendy University of Hawaii / High Energy Physics Group