HP-UX Reference (11i v3 07/02) - 3 Library Functions N-Z (vol 7)

r
rcmd(3N) rcmd(3N)
struct passwd *getpwuid();
char *host[] = { "hpxzgy" };
char *cmd = "date";
char *ruser = "chm";
main(argc,argv)
int argc;
char **argv;
{
struct servent *sp;
struct passwd *pwd;
FILE *fp;
char ch;
int rem;
sp = getservbyname("shell","tcp");
pwd = getpwuid(getuid());
rem = rcmd(host, sp->s_port, pwd->pw_name, ruser, cmd, 0);
if (rem < 0)
exit(1); /* rcmd outputs its own error messages */
fp = fdopen(rem, "r");
while ((ch = getc(fp)) != EOF)
putchar(ch);
}
WARNINGS
There is no way to specify options to the socket() call that rcmd() makes. Since rcmd() replaces the
pointer to the host name (
*ahost) with a pointer to the standard name of the host in a static data area, this
value must be copied into the user’s data area if it is to be used later. Otherwise, unpredictable results will
occur.
AUTHOR
rcmd() was developed by the University of California, Berkeley.
SEE ALSO
login(1), rlogin(1), remsh(1), named(1M), remshd(1M), rexecd(1M), gethostent(3N), rexec(3N),
hosts.equiv(4), thread_safety(5).
272 Hewlett-Packard Company 4 HP-UX 11i Version 3: February 2007