Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

sh(1)

exec(2)

fork(2)

wait(2)

system(3)



  system(3)                           CLIX                           system(3)



  NAME

    system - Issues a shell command

  LIBRARY

    Standard C Library (libc.a)

  SYNOPSIS

    #include <stdio.h>

    int system(
      char *string );

  PARAMETERS

    string   Points to the string containing the command to be executed by the
             shell.

  DESCRIPTION

    The function described in this manual page is based in the Standard C
    Library (libc.a).  For information about the system() function based in
    the FORTRAN Library (libF77.a), see the other system(3) reference manual
    entry.

    The system() function causes the string to be given to sh as input, as if
    the string had been typed as a command at a terminal.  The current process
    waits until the shell has completed, and then returns the exit status of
    the shell (as returned by the wait() function).

  EXAMPLES

    To execute the qpr command:

    qpr_func(data_type, queue, filename)
    char *data_type;
    char *queue;
    char *filename;
    {
         int     st;
         char    command[100];

         /*format a qpr command */
         sprintf(command, "qpr -t %s -q %s %s", data_type,
                 queue, filename);

         /*execute the command */
         st = system(command);
         if (st == 0) {



  2/94 - Intergraph Corporation                                              1






  system(3)                           CLIX                           system(3)



              printf("successful submission\n");
         }
         else {
              printf("submission failed\n");
         }
         ...

    In this example, the qpr command is given:

    ⊕  the type of data

    ⊕  the queue name

    ⊕  the filename

    If the printing command submits the job successfully, the function returns
    a value of 0, which causes the message

    successful submission

    to appear.  If any errors occur, the message

    submission failed

    appears.

  FILES

    /bin/sh   The shell that executes the command.

  RETURN VALUES

    The system() function forks to create a child process that in turn
    executes /bin/sh in order to execute string.  If the fork or the execute
    fails, system() returns a negative value and sets errno.  Otherwise, the
    function returns the exit status of the shell (as returned by the wait()
    function).

  RELATED INFORMATION

    Commands:   sh(1)

    Functions:  exec(2), fork(2), wait(2), system(3)











  2                                              Intergraph Corporation - 2/94




Typewritten Software • bear@typewritten.org • Edmonds, WA 98026