home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!stanford.edu!agate!dog.ee.lbl.gov!lbl.gov!vxwexplo
- From: crispen <@ada3.ca.boeing.com:crispen@efftoo.boeing.com>
- Newsgroups: comp.os.vxworks
- Subject: re: Remote shells and the rcmd() function
- Date: Tue, 17 Nov 92 08:45:58 CST
- Organization: Lawrence Berkeley Laboratory, Berkeley CA
- Lines: 82
- Sender: vxwexplo@lbl.gov
- Message-ID: <9211171445.AA02546@efftoo.boeing.com>
- NNTP-Posting-Host: 128.3.112.16
- Originator: daemon@vxw.ee.lbl.gov
-
- markm@ee.ubc.ca (mark milligan) asks about rcmd()
-
- Funny you should ask. I just wrote the following for Unix to test
- it out (the VME boxes are down).
-
- /*****************************************************************
- *
- * Illustrates the use of (Unix) rcmd
- *
- * The user on this system (who must be superuser) is prompted
- * for a string. The string is sent to a program on foxy called
- * rcmd_echo which reads it in and echos it out, capitalized.
- *
- *****************************************************************/
- #include <stdio.h>
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <netdb.h>
- main()
- {
- int c;
- int i=0;
- unsigned short inport = 514;
- char *host = "foxy";
- char **ahost = &host;
- char *locuser = "crispen";
- char *remuser = "crispen";
- char echo[100];
- char *cmd = "/home/crispen/rcmd_echo";
- char buffer[100];
- int fd2p = 0;
- int fd;
-
- fd = rcmd(ahost, inport, locuser, remuser, cmd, &fd2p);
- if (fd == -1)
- exit(1);
- printf("Connected\n");
- printf("Give me a string: ");
- while ((c=getc(stdin)) != '\n')
- echo[i++] = c;
- echo[i++] = '\n';
- echo[i] = '\0';
- write(fd, echo, strlen(echo));
- printf("Done with write\n");
- read(fd, buffer, 100);
- printf("%s", buffer);
- close(fd);
- }
-
- This talks to a guy called (as one might guess) rcmd_echo on a host called
- foxy:
-
- #include <stdio.h>
- #include <ctype.h>
- main()
- {
- int c;
- int i=0;
- int j;
- char buf[100];
- while ((c=getc(stdin)) != '\n')
- buf[i++] = c;
- buf[i++] = '\n';
- buf[i] = '\0';
- for (j=0; j<=i; j++)
- if (islower(buf[j]))
- buf[j] = toupper(buf[j]);
- printf("%s", buf);
- }
-
- That is, it takes a string in stdin and capitalizes it in stdout.
-
- Note that rcmd() is different in VxWorks (4.0.2) -- ahost is char** in
- Unix and char* in VxWorks.
-
- BTW, can anyone tell me before I try it if this works on 4.0.2? I
- know it does on 5.x, since they use it to download VxWorks.
- +-------------------------------+--------------------------------------+
- | Bob Crispen | Who will babysit the babysitters? |
- | crispen@foxy.boeing.com +--------------------------------------+
- | (205) 461-3296 |Opinions expressed here are mine alone|
- +-------------------------------+--------------------------------------+
-