home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / os / vxworks / 1022 < prev    next >
Encoding:
Text File  |  1992-11-17  |  2.7 KB  |  95 lines

  1. Path: sparky!uunet!stanford.edu!agate!dog.ee.lbl.gov!lbl.gov!vxwexplo
  2. From: crispen <@ada3.ca.boeing.com:crispen@efftoo.boeing.com>
  3. Newsgroups: comp.os.vxworks
  4. Subject: re:  Remote shells and the rcmd() function
  5. Date: Tue, 17 Nov 92 08:45:58 CST
  6. Organization: Lawrence Berkeley Laboratory, Berkeley CA
  7. Lines: 82
  8. Sender: vxwexplo@lbl.gov
  9. Message-ID: <9211171445.AA02546@efftoo.boeing.com>
  10. NNTP-Posting-Host: 128.3.112.16
  11. Originator: daemon@vxw.ee.lbl.gov
  12.  
  13. markm@ee.ubc.ca (mark milligan) asks about rcmd()
  14.  
  15. Funny you should ask.  I just wrote the following for Unix to test
  16. it out (the VME boxes are down).
  17.  
  18. /*****************************************************************
  19. *
  20. * Illustrates the use of (Unix) rcmd
  21. *
  22. * The user on this system (who must be superuser) is prompted
  23. * for a string.  The string is sent to a program on foxy called
  24. * rcmd_echo which reads it in and echos it out, capitalized.
  25. *
  26. *****************************************************************/
  27. #include <stdio.h>
  28. #include <sys/types.h>
  29. #include <sys/socket.h>
  30. #include <netdb.h>
  31. main()
  32. {
  33.     int c;
  34.     int i=0;
  35.     unsigned short inport = 514;
  36.     char *host = "foxy";
  37.     char **ahost = &host;
  38.     char *locuser = "crispen";
  39.     char *remuser = "crispen";
  40.     char echo[100];
  41.     char *cmd = "/home/crispen/rcmd_echo";
  42.     char buffer[100];
  43.     int fd2p = 0;
  44.     int fd;
  45.  
  46.     fd = rcmd(ahost, inport, locuser, remuser, cmd, &fd2p);
  47.     if (fd == -1)
  48.         exit(1);
  49.     printf("Connected\n");
  50.     printf("Give me a string: ");
  51.     while ((c=getc(stdin)) != '\n')
  52.         echo[i++] = c;
  53.     echo[i++] = '\n';
  54.     echo[i] = '\0';
  55.     write(fd, echo, strlen(echo));
  56.     printf("Done with write\n");
  57.     read(fd, buffer, 100);
  58.     printf("%s", buffer);
  59.     close(fd);
  60. }
  61.  
  62. This talks to a guy called (as one might guess) rcmd_echo on a host called
  63. foxy:
  64.  
  65. #include <stdio.h>
  66. #include <ctype.h>
  67. main()
  68. {
  69.         int c;
  70.         int i=0;
  71.         int j;
  72.         char buf[100];
  73.         while ((c=getc(stdin)) != '\n')
  74.                 buf[i++] = c;
  75.         buf[i++] = '\n';
  76.         buf[i] = '\0';
  77.         for (j=0; j<=i; j++)
  78.                 if (islower(buf[j]))
  79.                         buf[j] = toupper(buf[j]);
  80.         printf("%s", buf);
  81. }
  82.  
  83. That is, it takes a string in stdin and capitalizes it in stdout.
  84.  
  85. Note that rcmd() is different in VxWorks (4.0.2) -- ahost is char** in
  86. Unix and char* in VxWorks.
  87.  
  88. BTW, can anyone tell me before I try it if this works on 4.0.2?  I
  89. know it does on 5.x, since they use it to download VxWorks.
  90. +-------------------------------+--------------------------------------+
  91. | Bob Crispen                   |  Who will babysit the babysitters?   |
  92. | crispen@foxy.boeing.com       +--------------------------------------+
  93. | (205) 461-3296                |Opinions expressed here are mine alone|
  94. +-------------------------------+--------------------------------------+
  95.