HP OpenVMS Systems

ask the wizard
Content starts here

Command Input in C?

» close window

The Question is:

 
I have C program that using QIOs to get input from a terminal.  I have a need
 to run this from Batch and need to change the way the QIO's work.   The batch
 command file would be something like:
 
$ run my_program
input1
input2
input3
$ exit
 
  I know I have to skip around the getting and setting of the terminal
 characteristics, but I can't seem to get the QIO READVBLK to work.
 
1) To what device do you assign a channel in place of TT:, is it SYS$COMMAND or
 SYS$INPUT to get it to read the command file input?   I have tried both with
 the same results and TT: returns NL: device.
 
2) Other than SYS$ASSIGN(&cmd_name, &tty_chan, 0, 0), is there some more setup
 that must be done in BATCH mode?  Do I need to set up FABS and RABS?  If so,
 what do I specify for file information?
 
3) status = SYS$QIO(0, tty_chan, IO$READVBLK, &iosb, read_ast, 0, &data, 1, 0,
 &term_block, 0, 0)
 --- what needs to change in the above QIO call to read from the command file?
  Is the term_block causing the QIO to return a status of 99524 (%RMS-F-DEV,
 error in device name or inappropriate device type for operation)?  It appears
 that the QIO does not
 like using SYS$COMMAND or SYS$INPUT as input.
 
4) Are there any examples of using QIO to read batch command files from batch?
 Or redirecting from interactive terminal input to file input with QIOs?
 
5) Other than than the I/O Users Manual, is the other documentation I should be
 looking at?
 
Thank you for your assistance.
 


The Answer is :

 
  $qio processing here is far more programming effort than is likely
  necessary, and sscanf(), fgets(), lib$get_input() or similar would
  be far more common choices for obtaining input.  Even direct use of
  RMS is likely more effort than it is worth for user input.
 
  Accordingly, use of $qio implies other processing may be involved,
  such as an extended read, or specialized processing within the
  terminal.
 
  SYS$INPUT is the DCL command stream.  When interactive, the user
  enters this, typically ending a series of prompts with CTRL/Z; with
  an EOF.  From within a command procedure, the input can be embedded
  into the command stream and the first following $ command line will
  provide the CTRL/Z EOF.
 
  SYS$COMMAND is the user terminal, and typically not available
  within a batch job.
 
  TT: is a logical name associated with an interactive login, and
  specifically with the terminal.
 
  sys$qio is the asynchronous variant of the sys$qiow system service.
  Please see topic (1661) for related information.
 
  The OpenVMS Wizard would encourage a review of the programming
  concepts manual, the C documentation (and particularly the C
  run-time library manual), and the LIB run-time library reference
  manual.
 
  Examples of lib$get_input are posted in topics (3188) and (7008),
  and available from a variety of sources.  For another recent
  discussion of code examples, please see (8969).
 

answer written or last revised on ( 30-JUL-2003 )

» close window