× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On Fri, 12 Sep 2003, Urbanek, Marty wrote:
>
> 1 - Making a command with a hidden field and calling it via "system", but
> nothing appears on the screen when the command is called, regardless of
> various selective prompting characters I tried. It is as if once qsh has the
> screen, it has no way to relinquish control to anyone else.
>
> 2 - Making a CL and a DSPF with a hidden field and calling the CL via
> "system", but same results as #1. It is as if the CL is being invoked but
> its screem output goes nowhere.

The way that QSHELL works is that there are two jobs.  The first is your
interactive job (where you see the prompt, etc) the other is a background
job where teh actual programs are run.   They are connected by descriptors
0,1,2 (stdin, stdout, stderr) so that anything you type goes to stdin of
the other job, anything written to stderr or stdout gets printed on your
screen.

However, if you use a DSPF or a CMD object with the "system" command,
they do not attempt to use descriptors 0,1,2 for screen i/o, but rather
they try to talk to the screen directly.

What all of this means is that, when you do a "system" it runs in the
background (non-interactive) job.  That means that interactive programs
will fail.

>
> 3 - Using dynamic screen manager APIs. (Actually I never figured out how to
> tell DSM not to echo the input chars, but it was a moot point because the
> test didn't even get that far). I thought this would work for sure, but as
> soon as qhell "system" calls the DSM program, it blows up with "CPD0772:
> Program contains commands only valid when run interactively." Apparently it
> thinks of my interactive qshell session as a batch job.
>

Same problem.


>
> 4 - I didn't actually try it, but I was thinking of a simple C program to
> accept the input, but I cannot come up with a C/400 function that will not
> echo the input.
> Does anybody have any ideas how to do this?
>

The QSHELL uses something called "Generic Terminals" in order to implement
that 2-job approach I was discussing earlier.   There are Generic Terminal
APIs in the Information Center (Under "Unix-type APIs") that can do what
you're trying to do.

Here's a sample program that reads hidden input, and then echos it to
stdout.   Assuming you compiled this program into QGPL and called it
"GETPW", you'd use it in a script like this:

MYVAR=`/qsys.lib/qgpl.lib/getpw.pgm`

(make sure you use backquotes, regular quotes won't work)

Here's the sample code:

#include <stdio.h>
#include <stdlib.h>
#include <qp0ztrml.h>

#define MAXPW 80

int main(int argc, char **argv) {

    char pw[MAXPW+1];
    int len;
    int is_a_term;

    is_a_term = Qp0zIsATerminal(0);

    if (is_a_term) {
       Qp0zSetTerminalMode(QP0Z_TERMINAL_INPUT_MODE,
                           QP0Z_TERMINAL_HIDDEN, NULL);
    }

    fgets(pw, MAXPW, stdin);

    len = strlen(pw);
    while (pw[--len]=='\r' || pw[len]=='\n') pw[len]='\0';

    if (is_a_term) {
        Qp0zSetTerminalMode(QP0Z_TERMINAL_INPUT_MODE,
                            QP0Z_TERMINAL_PREVIOUS, NULL);
    }

    fprintf(stdout, "%s", pw);

    return 0;
}

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.