DCL 编程 - 远程连接

DCL Programming - Remote connections

首先,我是一个新手,不应该被允许在键盘周围。也就是说,我正在尝试编写一个 DCL .COM 文件,允许用户通过从列表中选择它来连接到远程设备。

我只想让他们选择一个设备并连接,然后当他们与设备断开连接时,回到他们开始的地方。在我终止远程连接后,它一直把我甩出去。

操作系统是OpenVMS。这是代码(其中 xxx.xxx.xxx.xxx 将是远程系统的 IP 地址)。

任何帮助将不胜感激!

$!      MRV Terminal Server Connection Menu
$!       
$ ON ERROR THEN $ LOGOUT
$ GOMENU:
$!
$ CLS:==SET TERM/WIDTH=80
$ WT:==WRITE SYS$OUTPUT
$!
$ CLS
$ WT "   MRV Terminal Server Connection Menu "
$ WT " "
$ WT "  1     MRV 1"
$ WT "  2     MRV 2"
$ WT "  3     MRV 3"
$ WT "  4     MRV 4" 
$ WT "  5     MRV 5"
$ WT "  6     MRV 6"
$ WT "  7     MRV 7"
$ WT "  8     MRV 8"
$ WT "  9     MRV 9"
$ WT "  10     MRV 10"
$ WT "  11     MRV 11"
$ WT "  12     MRV 12"
$ WT "  13     MRV 13"
$ WT "  14     MRV 14"  
$ WT " "
$ WT " "
$ WT " "
$ WT " "
$ WT " "                                    
$ WT "  X     EXIT"
$ WT " "
$ INQUIRE ANS "Select the MRV you wish to connect to:"
$!
$!
$  IF ANS .EQS. "X" then goto goodbye
$!                                          
$!
$  IF ANS .EQS. "1" then SSH "InReach@xxx.xxx.xxx.xxx"
$!
$  IF ANS .EQS. "2" then SSH "InReach@xxx.xxx.xxx.xxx"    
$!
$  IF ANS .EQS. "3" then SSH "InReach@xxx.xxx.xxx.xxx"
$!
$  IF ANS .EQS. "4" then SSH "InReach@xxx.xxx.xxx.xxx"
$!
$  IF ANS .EQS. "5" then SSH "InReach@xxx.xxx.xxx.xxx" 
$!
$  IF ANS .EQS. "6" then SSH "InReach@xxx.xxx.xxx.xxx"
$!
$  IF ANS .EQS. "7" then SSH "InReach@xxx.xxx.xxx.xxx"   
$!
$  IF ANS .EQS. "8" then SSH "InReach@xxx.xxx.xxx.xxx"   
$!
$  IF ANS .EQS. "9" then SSH "InReach@xxx.xxx.xxx.xxx"  
$!
$  IF ANS .EQS. "10" then SSH "InReach@xxx.xxx.xxx.xxx"   
$!                                          
$  IF ANS .EQS. "11" then SSH "InReach@xxx.xxx.xxx.xxx"
$!                                                
$  IF ANS .EQS. "12" then SSH "InReach@xxx.xxx.xxx.xxx"        
$!            
$  IF ANS .EQS. "13" then SSH "InReach@xxx.xxx.xxx.xxx"
$!             
$ GOODBYE:
$!EXIT

这可能更符合您的喜好:

$ ! MRV Terminal Server Connection Menu
$ !       
$ CLS :== SET TERMINAL/WIDTH=80
$ WT :== WRITE SYS$OUTPUT
$ !
$ Menu:
$ !
$ ! If SSH (or anything else) causes an error, go back to the menu.
$ !   It is placed here because it needs to be set again after each error.
$ on error then $ goto Menu
$ !
$ CLS
$ WT "   MRV Terminal Server Connection Menu "
$ WT " "
$ WT "  1     MRV 1"
$ WT "  2     MRV 2"
$ WT "  3     MRV 3"
$ WT "  4     MRV 4" 
$ WT "  5     MRV 5"
$ WT "  6     MRV 6"
$ WT "  7     MRV 7"
$ WT "  8     MRV 8"
$ WT "  9     MRV 9"
$ WT "  10     MRV 10"
$ WT "  11     MRV 11"
$ WT "  12     MRV 12"
$ WT "  13     MRV 13"
$ WT "  14     MRV 14"  
$ WT " "
$ WT " "
$ WT " "
$ WT " "
$ WT " "                                    
$ WT "  X     EXIT"
$ WT " "
$ !
$ INQUIRE ANS "Select the MRV you wish to connect to:"
$ !
$ if Ans .eqs. "X"
$   then
$   goto Houseclean
$ else if Ans .eqs. "1"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "2"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "3"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "4"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "5"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "6"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "7"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "8"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "9"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "10"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "11"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "12"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else if Ans .eqs. "13"
$   then
$   SSH "InReach@xxx.xxx.xxx.xxx"
$ else
$   ! Handle any unexpected input.
$   WT "Beg your pardon?" ! Immediately followed by clearing the screen.  Sigh.
$   endif
$ !
$ ! We did what they wanted.  How else may we serve?
$ goto Menu
$ !             
$ Houseclean:
$   ! Nothing else to do.
$   exit ! Or perhaps you prefer $ logout
  1. 不要搞乱终端设置!
  2. INQUIRE 很糟糕,通常情况下,但现在已经足够好了。
  3. 对大块常量文本使用 TYPE
  4. Table 查找或关联数组比长 IF THEN ELSES
  5. 更清晰
  6. 使用 F$TYPE 查看符号是 STRING、INTEGER 还是 NOTHING-AT-ALL

查看此内容以获取一些想法:

$ ! MRV Terminal Server Connection Menu
$ !
$ CLS :== TYPE/PAGE NL: !  Please don't muck with my screen setting as in: SET TERMINAL/WIDTH=80
$ WT :== WRITE SYS$OUTPUT
$ ANS_1  =  "aap.xxx.xxx.xxx"
$ ANS_2  = "noot.xxx.xxx.xxx"
$ ANS_14 = "mies.xxx.xxx.xxx"
$ !
$ Menu:
$ !
$ ! If SSH (or anything else) causes an error, go back to the menu.
$ !   It is placed here because it needs to be set again after each error.
$ on error then $ goto Menu
$ !
$ type/page sys$input:

   MRV Terminal Server Connection Men

  1     MRV 1
  2     MRV 2
  :
  14    MRV 14

  X     EXIT"
$ !
$ INQUIRE ANS "Select the MRV you wish to connect to:"
$ !
$ if ANS .eqs. "X" then exit
$ if f$type(ANS_'ANS') .eqs. ""
$ then
$   ! Handle any unexpected input.
$   WT "Beg your pardon? ''ANS' ? " ! Immediately followed by clearing the screen.  Sigh.
$   WAIT 0:0:3
$ !
$ ! We did what they wanted.  How else may we serve?
$   goto Menu
$ endif
$  command = "SSH """ +  ANS_'ANS + """"
$ write sys$output "Going to execute : " + command
$
$!  'command      ! Remove Comment for real action