Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rexec(3X) — HP-UX 5.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

rexecd(1M)

rcmd(3X)

netrc(5)

     REXEC(3X)                Series 300 Only                REXEC(3X)

     NAME
          rexec - return stream to a remote command

     SYNOPSIS
          int rem
          rem = rexec(ahost, inport, user, passwd, cmd, fd2p);
          char **ahost;
          int inport;
          char *user, *passwd, *cmd;
          int *fd2p;

     HP-UX COMPATIBILITY
          Level:    HP-UX/NON-STANDARD

          Origin:   UCB

          Remarks:  Implemented on the Series 300 only.

     DESCRIPTION
          This library can be accessed by giving the  -lbsdipc  option
          to ld(1).

          Rexec looks up the host *ahost using  gethostbyname(3N)  and
          returns  -1 if the host does not exist.  The hostname can be
          either  the  official  name  or  an  alias  as   listed   in
          /etc/hosts;  see  hosts(5).   Otherwise *ahost is set to the
          standard name of the host.  If a username and  password  are
          both  specified,  then these are used to authenticate to the
          foreign host; otherwise the  user's  .netrc  (see  netrc(5))
          file  in  his  home  directory  are searched for appropriate
          information.  If all this fails, the user  is  prompted  for
          the   information.   When  the  user  is  prompted  for  the
          information, the default used for the remote  user  name  is
          the local user name and the default password is no password.

          The port inport specifies which DARPA internet port  to  use
          for  the  connection; it is normally the value returned from
          the call getservbyname("exec", "tcp") (see  getservent(3N)).
          The  protocol  for  connection  is  described  in  detail in
          rexecd(1M).

          If the call  succeeds,  a  socket  of  type  SOCK_STREAM  is
          returned  to  the caller, and given to the remote command as
          stdin and stdout.   If  the  connection  to  the  socket  is
          refused  after five tries, or if it was refused for a reason
          other than the port being in use, then rexec returns  a  -1.
          If  fd2p  is  non-zero,  then  a  auxiliary  connection to a
          control process is setup, and a descriptor for it is  placed
          in  *fd2p.   The  control  process returns diagnostic output
          from the command on this connection, and also accepts  bytes
          on  this  connection  as  being  UNIX  signal numbers, to be
          forwarded to the process  group  of  the  command.   If  the

     Hewlett-Packard               - 1 -             (printed 7/16/86)

     REXEC(3X)                Series 300 Only                REXEC(3X)

          auxiliary  port  cannot  be set up, then rexec returns a -1.
          If fd2p is 0, then stderr of the remote command is made  the
          same  as  stdout  and  no  provision  is  made  for  sending
          arbitrary signals to the remote process.

          Note: There is no way to specify options to the socket  call
          which rexec makes.

     EXAMPLES
          To execute the command date on the  remote  host  ``hpxzgy''
          using  the  remote  account  ``chm''  you  can  use rexec as
          follows:

          #include <sys/types.h>
          #include <sys/socket.h>
          #include <netinet/in.h>
          #include <netdb.h>
          #include <stdio.h>

          main(argc, argv)
               char **argv;
               int argc;
          {
               char ch;
               char *user = "chm";
               char *passwd = "password";
               char *cmd = "date";
               struct servent *servent;
               FILE *fp;
               int sd;
               static char ahost[25] = "hpxzgy";

               servent = getservbyname("exec", "tcp");
               sd = rexec( &ahost, servent->s_port, user, passwd, cmd, 0);
               fp = fdopen(sd, "r");
               while ((ch = getc(fp)) != EOF)
                    putchar(ch);
          }

     DIAGNOSTICS
          The diagnostic messages for rexec are the following:

          <hostname>: Unknown host
               Remote host name not found in /etc/hosts.

          <system call>:...
               Error  in  executing  the  system  call.    A   message
               specifying the cause of the failure is appended to this
               message.

          connect: <hostname>:...

     Hewlett-Packard               - 2 -             (printed 7/16/86)

     REXEC(3X)                Series 300 Only                REXEC(3X)

               Error in connecting to the socket obtained  for  rexec.
               A  message  specifying  the  cause  of  the  failure is
               appended to this diagnostic.

          Secondary socket
               Error  in  creating  a  secondary  socket   for   error
               transmission to be used by rexec.

          read: <hostname>:...
               Error  in  reading  information  transmitted  over  the
               socket.   A message specifying the cause of the failure
               is appended to this diagnostic.

          Connection timeout
               The remote host did not connect within  30  seconds  to
               the secondary socket set up as an error connection.
          Lost connection
               The program attempts to read from the socket and fails.
               This  means  the socket connection with the remote host
               was lost.

          .netrc:...
               Error in opening .netrc file in the home directory, for
               a reason other than the file not existing.

     mode.
          Error-
                .netrc file not correct mode. Remove password  or  correct
               The .netrc file is readable, writable or executable  by
               anyone else other than the user.

               Next step: Check if .netrc has  not  been  modified  by
               someone  else  and  change  mode  of  .netrc (chmod 400
               .netrc).

          Unknown .netrc option ...
               A keyword not recognized has been found in .netrc  (see
               netrc(5)).

               Next step: Correct keyword in .netrc.

     SEE ALSO
          rexecd(1M), rcmd(3X), netrc(5).

     WARNINGS
          A program using rexec should not be put  in  the  background
          when rexec is expected to prompt for a password or username.
          If it is put on the background  it  will  compete  with  the
          shell for input.

     Hewlett-Packard               - 3 -             (printed 7/16/86)

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