home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxnet2.zip / NU.CMD < prev    next >
OS/2 REXX Batch file  |  1993-08-04  |  2KB  |  109 lines

  1. /*
  2.     N E T U S E . C M D
  3.  
  4.     Net Use in REXX
  5.  
  6.     Usage:  NU drive alias
  7.             NU drive UNCpath
  8.             NU drive /D
  9.             NU LPTx  alias
  10.             NU LPTx UNCpath
  11.             NU LPTx /D
  12. */
  13.  
  14. call rxfuncadd SysLoadFuncs, REXXUTIL, SysLoadFuncs
  15. call SysLoadFuncs
  16. call rxfuncadd NetLoadFuncs, "RexxNet", NetLoadFuncs
  17. call NetLoadFuncs
  18. if rxfuncquery('NetAliasGetInfo') then do
  19.     say "Rexx Network DLL is not available"
  20.     signal finish
  21. end
  22.  
  23. parse upper arg Drive Alias
  24.  
  25. if Drive = '' then do
  26.     call Display
  27.     retc = 0
  28.     signal finish
  29. end
  30. if Drive = '/?' then do
  31.     call Help
  32.     retc = 0
  33.     signal finish
  34. end
  35. retc = NetUseGetInfo('', Drive, 1, 'NetUse')
  36. select
  37.     when retc = 0 then do
  38.         retc = NetUseDel('', Drive, 2)
  39.         if retc \= 0 then
  40.             signal error
  41.         end
  42.     when retc = 2250 then do
  43.         NetUse.Local = Drive
  44.         if Length(Drive) >= 4 then
  45.             NetUse.Asg_Type = 1
  46.         else
  47.             NetUse.Asg_Type = 0
  48.     end
  49.     otherwise
  50.         signal error
  51. end
  52. if Alias = '/D' then do
  53.     retc = NetUseDel('', Drive, 2)
  54.     if retc \= 0 then do
  55.         if retc \= 2250 then
  56.             signal error
  57.     end
  58.     signal finish
  59. end
  60. if Left(Alias, 2) = '\\' then
  61.     NetUse.Remote = Alias
  62. else do
  63.     retc = NetAliasGetInfo('', Alias, 2, "NetAlias")
  64.     if retc \= 0 then
  65.         signal error
  66.     NetUse.Remote = NetAlias.Server||'\'||NetAlias.NetName
  67. end
  68. say NetUse.Local NetUse.Remote NetUse.Asg_type
  69.  
  70. retc = NetUseAdd('', 1, "NetUse")
  71. if rect \= 0 then
  72.     signal error
  73.  
  74. say Drive NetUse.Remote
  75. signal finish
  76.  
  77. display:
  78. retc = NetUseEnum('', 1, "NetUse")
  79. do i = 0 to NetUse.Entries - 1
  80.     if NetUse.i.Local \= '' then
  81.         say NetUse.i.Local "    " NetUse.i.Remote
  82.     else
  83.         say "        " NetUse.i.Remote
  84. end
  85. return
  86.  
  87. help:
  88. say "Usage:"
  89. say " NU Drive Alias"
  90. say " NU Drive \\server\sharename"
  91. say " NU Drive /D"
  92. return
  93.  
  94. error:
  95.  
  96. if retc \= 0 then do
  97.     if retc < 2100 then
  98.         say SysGetMessage(retc)
  99.     else
  100.         say SysGetMessage(retc, "NET.MSG")
  101. end
  102.  
  103. finish:
  104.  
  105. call NetDropFuncs
  106. call SysDropFuncs
  107. exit retc
  108.  
  109.