home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / srev13g.zip / DODELETE.CMD < prev    next >
OS/2 REXX Batch file  |  1996-07-13  |  2KB  |  70 lines

  1. /* DODELETE.CMD -- delete files from http server using DELETE http method  */
  2. /* ------------------------------------------------------------------- */
  3. /* Call as:  MOVEAUD serveraddress url_to_delete                     */
  4. /* ------------------------------------------------------------------- */
  5. /* This program requires that the RxSock.DLL be in your LIBPATH (it is */
  6. /* usually in your \TCPIP\DLL directory.  It was shipped with the      */
  7. /* August 1994 CSD for the TCP/IP base (UN64092).                      */
  8.  
  9. call load /* load functions if necessary */
  10.  
  11. say " Program to DELETE files from an HTTP server using the PUT verb "
  12.  
  13.  
  14. parse arg server request .
  15.  
  16. if server="" then do 
  17.    say " Reminder: the HTTP server must support the DELETE http method "
  18.    say "  (you may also require special access privileges) "
  19.  
  20.     say " Please enter server address: "
  21.     parse pull server
  22. end  /* Do */
  23. if request="" then  do
  24.   say " Please enter url to use (on " server "): "
  25.   parse pull request
  26. end
  27.  
  28. crlf    ='0d0a'x                        /* constants */
  29. family  ='AF_INET'
  30. httpport=80
  31.  
  32. rc=sockgethostbyname(server, "serv.0")  /* get dotaddress of server */
  33. if rc=0 then do; say 'Unable to resolve "'server'"'; exit; end
  34. dotserver=serv.0addr                    /* .. */
  35.  
  36. gosaddr.0family=family                  /* set up address */
  37. gosaddr.0port  =httpport
  38. gosaddr.0addr  =dotserver
  39.  
  40. gosock = SockSocket(family, "SOCK_STREAM", "IPPROTO_TCP")
  41.  
  42. message='DELETE /'request' HTTP/1.0'crlf||crlf
  43. say message
  44.  
  45.  
  46. got=''
  47. rc = SockConnect(gosock,"gosaddr.0")
  48. if rc<0 then do; say 'Unable to connect to "'server'"'; exit; end
  49. rc = SockSend(gosock, message)
  50. say " rc " rc
  51. /* Now wait for the response */
  52. do r=1 by 1
  53.   rc = SockRecv(gosock, "response", 1000)
  54.   got=got||response
  55.   /* say '>'rc'>' response */
  56.   if rc<=0 then leave
  57.   end r
  58. rc = SockClose(gosock)
  59.  
  60. say 'Got' length(got) 'bytes of response:'
  61. say  got
  62. exit
  63.  
  64. /* --- Load the function library, if necessary --- */
  65. load:
  66. if \RxFuncQuery("SockLoadFuncs") then return      /* already there */
  67. call RxFuncAdd "SockLoadFuncs","rxSock","SockLoadFuncs"
  68. call SockLoadFuncs
  69. return
  70.