home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / goserv.zip / moveaud.cmd < prev   
OS/2 REXX Batch file  |  1995-01-25  |  2KB  |  61 lines

  1. /* MOVEAUD.CMD -- remote control of a GoServe server                   */
  2. /* ------------------------------------------------------------------- */
  3. /* This sample command program sends a HTTP (Web) request to a server, */
  4. /* with the default being the '!save' request that the sample filter   */
  5. /* uses to trigger a Move Audit command.  Easily modified for other    */
  6. /* remote control actions, or to be a general 'home page retriever'.   */
  7. /* ------------------------------------------------------------------- */
  8. /* Call as:  MOVEAUD [serveraddress [requeststring]]                   */
  9. /* ------------------------------------------------------------------- */
  10. /* This program requires that the RxSock.DLL be in your LIBPATH (it is */
  11. /* usually in your \TCPIP\DLL directory.  It was shipped with the      */
  12. /* August 1994 CSD for the TCP/IP base (UN64092).                      */
  13.  
  14. call load /* load functions if necessary */
  15.  
  16. parse arg server request .
  17. if server=''  then server='your.server.here'
  18. if request='' then request="!save"
  19.  
  20. crlf    ='0d0a'x                        /* constants */
  21. family  ='AF_INET'
  22. httpport=80
  23.  
  24. rc=sockgethostbyname(server, "serv.0")  /* get dotaddress of server */
  25. if rc=0 then do; say 'Unable to resolve "'server'"'; exit; end
  26. dotserver=serv.0addr                    /* .. */
  27.  
  28. gosaddr.0family=family                  /* set up address */
  29. gosaddr.0port  =httpport
  30. gosaddr.0addr  =dotserver
  31.  
  32. gosock = SockSocket(family, "SOCK_STREAM", "IPPROTO_TCP")
  33.  
  34. /* Set up request [HTTP 0.9 style, for all servers] */
  35. message="GET /"request''crlf
  36.  
  37. got=''
  38. rc = SockConnect(gosock,"gosaddr.0")
  39. if rc<0 then do; say 'Unable to connect to "'server'"'; exit; end
  40. rc = SockSend(gosock, message)
  41.  
  42. /* Now wait for the response */
  43. do r=1 by 1
  44.   rc = SockRecv(gosock, "response", 1000)
  45.   got=got||response
  46.   /* say '>'rc'>' response */
  47.   if rc<=0 then leave
  48.   end r
  49. rc = SockClose(gosock)
  50.  
  51. say 'Got' length(got) 'bytes of response:'
  52. say got
  53. exit
  54.  
  55. /* --- Load the function library, if necessary --- */
  56. load:
  57. if \RxFuncQuery("SockLoadFuncs") then return      /* already there */
  58. call RxFuncAdd "SockLoadFuncs","rxSock","SockLoadFuncs"
  59. call SockLoadFuncs
  60. return
  61.