CREATEPROCESS and other questions... - Hewlett Packard

This is a discussion on CREATEPROCESS and other questions... - Hewlett Packard ; Hello, I am porting a C application over to MPE/iX and I have some questions regarding CREATEPROCESS. It seems CREATEPROCESS only lets me launch an executable program. What do I need to use if I wanted to STREAM a job ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: CREATEPROCESS and other questions...

  1. CREATEPROCESS and other questions...

    Hello,

    I am porting a C application over to MPE/iX and I have some questions
    regarding CREATEPROCESS. It seems CREATEPROCESS only lets me launch an
    executable program. What do I need to use if I wanted to STREAM a job or
    run an internal command such as a LISTFILE? Also, when using CREATEPROCESS,
    the executable in which I want to launch will only launch if the executable
    is in the same group as my application.

    Thanks
    Mike Miles

    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  2. Re: CREATEPROCESS and other questions...

    Mike asked:

    > I am porting a C application over to MPE/iX and I have some questions
    > regarding CREATEPROCESS. It seems CREATEPROCESS only lets me launch

    an
    > executable program. What do I need to use if I wanted to STREAM a job

    or
    > run an internal command such as a LISTFILE? Also, when using
    > CREATEPROCESS,
    > the executable in which I want to launch will only launch if the
    > executable
    > is in the same group as my application.


    For an easy way to execute commands from a C program, try the system()
    function. It calls HPCICOMMAND for you, and you don't have to append a
    carriage-return.

    You can even use it to execute a RUN command, so you might not need to
    use CREATEPROCESS.

    Here's a sample program.

    -----cut here-----
    #include
    #include
    int main(void)
    {
    int return_value;
    /* Invoke our favorite text editor */
    return_value=system("RUN EDITOR.PUB.SYS");
    if (!return_value)
    {
    puts("Everything is fine!");
    return EXIT_SUCCESS;
    }
    else
    {
    puts("*** OOPS! ***");
    return EXIT_FAILURE;
    }
    }
    -----cut here-----

    Walter

    Walter J. Murray

    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  3. Re: CREATEPROCESS and other questions...

    I am still receiving the same error.

    My code is:

    //cmd is put on the stack and a command line like LISTFILE is put into it
    *(cmdline+strlen(cmdline)+1) = (char)15;
    HPCICOMMAND(cmdline, &createstatus);

    This should overwrite the null terminator with a carriage return. I have
    also tried strcat(cmdline , "\r"), strcat(cmdline, "\r "); and basically
    every combination of a space and a carriage return, with a null terminator
    and without. I have also tried using (char)15 instead of \r and that didnt
    work. I have also tried memsetting the whole buffer to 15 or '\r'.



    On Mon, Jul 7, 2008 at 11:20 PM, Walter J. Murray
    wrote:

    > Mike asked:
    >
    > > I am porting a C application over to MPE/iX and I have some questions
    > > regarding CREATEPROCESS. It seems CREATEPROCESS only lets me launch

    > an
    > > executable program. What do I need to use if I wanted to STREAM a job

    > or
    > > run an internal command such as a LISTFILE? Also, when using
    > > CREATEPROCESS,
    > > the executable in which I want to launch will only launch if the
    > > executable
    > > is in the same group as my application.

    >
    > For an easy way to execute commands from a C program, try the system()
    > function. It calls HPCICOMMAND for you, and you don't have to append a
    > carriage-return.
    >
    > You can even use it to execute a RUN command, so you might not need to
    > use CREATEPROCESS.
    >
    > Here's a sample program.
    >
    > -----cut here-----
    > #include
    > #include
    > int main(void)
    > {
    > int return_value;
    > /* Invoke our favorite text editor */
    > return_value=system("RUN EDITOR.PUB.SYS");
    > if (!return_value)
    > {
    > puts("Everything is fine!");
    > return EXIT_SUCCESS;
    > }
    > else
    > {
    > puts("*** OOPS! ***");
    > return EXIT_FAILURE;
    > }
    > }
    > -----cut here-----
    >
    > Walter
    >
    > Walter J. Murray
    >
    >
    >


    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  4. Re: CREATEPROCESS and other questions...

    Mike,

    The Cobol sample used "%15" to include a carriage-return. This is an octal value so the actual decimal equivalent is 13. So, I think it should be "(char) 13" and not "(char)15".

    I believe "\r" should have worked in C however.

    HTH
    François

    ________________________________

    From: HP-3000 Systems Discussion on behalf of Michael Mileusnich
    Sent: Tue 7/8/2008 3:36 PM
    To: HP3000-L@RAVEN.UTC.EDU
    Subject: Re: [HP3000-L] CREATEPROCESS and other questions...



    I am still receiving the same error.

    My code is:

    //cmd is put on the stack and a command line like LISTFILE is put into it
    *(cmdline+strlen(cmdline)+1) = (char)15;
    HPCICOMMAND(cmdline, &createstatus);

    This should overwrite the null terminator with a carriage return. I have
    also tried strcat(cmdline , "\r"), strcat(cmdline, "\r "); and basically
    every combination of a space and a carriage return, with a null terminator
    and without. I have also tried using (char)15 instead of \r and that didnt
    work. I have also tried memsetting the whole buffer to 15 or '\r'.



    On Mon, Jul 7, 2008 at 11:20 PM, Walter J. Murray
    wrote:

    > Mike asked:
    >
    > > I am porting a C application over to MPE/iX and I have some questions
    > > regarding CREATEPROCESS. It seems CREATEPROCESS only lets me launch

    > an
    > > executable program. What do I need to use if I wanted to STREAM a job

    > or
    > > run an internal command such as a LISTFILE? Also, when using
    > > CREATEPROCESS,
    > > the executable in which I want to launch will only launch if the
    > > executable
    > > is in the same group as my application.

    >
    > For an easy way to execute commands from a C program, try the system()
    > function. It calls HPCICOMMAND for you, and you don't have to append a
    > carriage-return.
    >
    > You can even use it to execute a RUN command, so you might not need to
    > use CREATEPROCESS.
    >
    > Here's a sample program.
    >
    > -----cut here-----
    > #include
    > #include
    > int main(void)
    > {
    > int return_value;
    > /* Invoke our favorite text editor */
    > return_value=system("RUN EDITOR.PUB.SYS");
    > if (!return_value)
    > {
    > puts("Everything is fine!");
    > return EXIT_SUCCESS;
    > }
    > else
    > {
    > puts("*** OOPS! ***");
    > return EXIT_FAILURE;
    > }
    > }
    > -----cut here-----
    >
    > Walter
    >
    > Walter J. Murray
    >
    >
    >


    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

    Remarque - Cette transmission est pour l'usage exclusif du ou des destinataires indiqués et peut contenir de l'information confidentielle ou protégée. Si vous n'êtes pas le destinataire indiqué, veuillez supprimer cette transmission ainsi que tout fichier joint et aviser l'expéditeur par courriel immédiatement. Toute révision, utilisation, divulgation ou distribution non autorisée est interdite.


    Notice: This transmission is for the sole use of the intended recipient(s) and may contain information that is confidential and/or privileged. If you are not the intended recipient, please delete this transmission and any attachments and notify the sender by return email immediately. Any unauthorized review, use, disclosure or distribution is prohibited.

    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  5. Re: CREATEPROCESS and other questions...

    Your offset calculation is incorrect in your statement.
    Try the following sample:
    Pardon the "LookOut-applied" text alignment.

    (I compile with CCOPTS "-Aa -C +e +w1")

    #pragma list off
    #include
    #include
    #pragma intrinsic COMMAND
    #pragma intrinsic HPCICOMMAND
    int main ()
    {
    int x;
    short ierr, iparm;
    char cmdline [50];
    ierr = 0;
    /* examples of system, COMMAND */
    x = system ( "listf xl@.pub.sys,2" );
    printf ( "system=%d\n", x );
    sleep (2);

    COMMAND ( "listf xl@.pub.sys,2\r", &ierr, &iparm );
    printf ( "COMMAND err %d\n", ierr );
    sleep (2);

    sprintf ( cmdline, "listf %s,2\r", "xl@.pub.sys" );
    COMMAND ( cmdline, &ierr, &iparm );
    printf ( "COMMAND err %d\n", ierr );
    sleep (2);

    sprintf ( cmdline, "listf xl@.pub.sys,2" );
    printf ( "len %d line [%s]\n", strlen (cmdline), cmdline );
    printf ( "Your statement has an incorrect offset for the return\n" );

    /* Your statement */
    /*cmd is put on the stack and a command line like LISTFILE is put into it*/
    *(cmdline+strlen(cmdline)+1) = '\r';
    ierr = 0;
    HPCICOMMAND ( cmdline, &ierr );
    printf ( "HPCICOM %d\n", ierr );
    sleep (2);

    /* Your offset for the return is off by +1 */
    printf ( "You didn't need the +1\n" );
    *(cmdline +strlen(cmdline)) = '\r';
    ierr = 0;
    HPCICOMMAND ( cmdline, &ierr );
    printf ( "HPCICOM %d\n", ierr );
    sleep(2);

    /* personally, since I've done some in language translation
    and rewrite, I prefer to avoid my own pointer arithmetic */
    cmdline [strlen(cmdline)] = '\r';
    HPCICOMMAND ( cmdline, &ierr );
    printf ( "HPCICOM %d\n", ierr );
    }

    :run $oldpass
    ACCOUNT= SYS GROUP= PUB
    FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
    SIZE TYP EOF LIMIT R/B SECTORS #X MX
    XL * NMXL 128W FB 105889 4096000 1 106496 55 *

    system=0
    ACCOUNT= SYS GROUP= PUB
    FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
    SIZE TYP EOF LIMIT R/B SECTORS #X MX
    XL * NMXL 128W FB 105889 4096000 1 106496 55 *

    COMMAND err 0
    ACCOUNT= SYS GROUP= PUB
    FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
    SIZE TYP EOF LIMIT R/B SECTORS #X MX
    XL * NMXL 128W FB 105889 4096000 1 106496 55 *

    COMMAND err 0
    len 19 line[listf xl@.pub.sys,2]
    Your statement has an incorrect offset for the return
    listf xl@.pub.sys,2
    ^
    Level of LISTF must be -5, or within the range -3 to 9. (CIWARN 420)
    ACCOUNT= SYS GROUP= PUB
    FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
    SIZE TYP EOF LIMIT R/B SECTORS #X MX
    XL * NMXL 128W FB 105889 4096000 1 106496 55 *

    HPCICOM -420
    You didn't need the +1
    ACCOUNT= SYS GROUP= PUB
    FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
    SIZE TYP EOF LIMIT R/B SECTORS #X MX
    XL * NMXL 128W FB 105889 4096000 1 106496 55 *

    HPCICOM 0
    ACCOUNT= SYS GROUP= PUB
    FILENAME CODE ------------LOGICAL RECORD----------- ----SPACE----
    SIZE TYP EOF LIMIT R/B SECTORS #X MX
    XL * NMXL 128W FB 105889 4096000 1 106496 55 *

    HPCICOM 0
    End Run


    Keven Miller

    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


  6. Re: CREATEPROCESS and other questions...

    You didn't mention if you solved your problem
    with HPCICOMMAND (AFAIK).

    (best viewed with fixed font)

    In:
    //cmd is put on the stack and a command line like LISTFILE is put into it
    *(cmdline+strlen(cmdline)+1) = (char)15;
    HPCICOMMAND(cmdline, &createstatus);

    This should overwrite the null terminator with a carriage return. I have
    also tried strcat(cmdline , "\r

    there are a number of problems:

    1. readability in C

    You always want: cmdline [...] = ...
    where possible ... it makes things easier for the reader,
    and produces the same for the emitted code.

    2. the index calculation is wrong.

    Combining #1 and #2 we should get:

    cmdline [strlen (cmdline)] = (char) 15;

    Of course, from the viewpoint of getting a CR at the end,
    that's similar to the strcat you tried (of course, the strcat
    also appends a null, but HPCICOMMAND won't care).

    I.e., this fix won't solve your problem by itself, so ...

    3. calling sequence

    I didn't see if you were using "#pragma intrinsic HPCICOMMAND", which
    is only in HP's C compiler.

    Assuming you aren't, then you've got a major problem with
    the parameters ... you're missing the first (and hidden) parameter.

    Here's the real calling sequence from gcc's viewpoint (or HP C if
    you don't use #pragma intrinsic HPCICOMMAND)...

    extern void HPCICOMMAND (
    int32 num_actual_parms,
    void *cmdimage,
    int16_t *cmderror,
    int16_t *parmnum,
    int16_t msglevel);

    Thus, your call should be:

    HPCICOMMAND (2, cmdimage, &cmderror, NULL, 0);

    you could use "4" instead of "2", in this case;
    you may want a msglevel other than 0

    Now, you're saying "how do I find out which intrinsics have a hidden
    '# of parameters' parameter at the start?". Good question!

    The CSEQ tool, a product from Lund Peformance Solutions, provides the
    information. I got the above by entering:

    :cseq -gcc hpcicommand

    Although I wrote CSEQ, I don't think we have a financial interest
    in it so I'm not going to say .

    CSEQ is **HIGHLY** recommended if you're doing calls to intrinsics from C!

    Stan.

    --
    Stan Sieler
    sieler@allegro.com
    www.allegro.com/sieler/wanted/index.html

    * To join/leave the list, search archives, change list settings, *
    * etc., please visit http://raven.utc.edu/archives/hp3000-l.html *


+ Reply to Thread