Board logo

标题: [系统相关] bat转换sh在linux中执行 [打印本页]

作者: ihubert    时间: 2018-9-10 13:23     标题: bat转换sh在linux中执行

请问.bat的批处理文件如何在linux下执行。具体如下:
  1. @echo off
  2. setlocal EnableDelayedExpansion
  3. echo VirtualBox Hider for SolidWorks
  4. echo by TeAM SolidSQUAD-SSQ
  5. if "%1"=="" goto usage
  6. set VMNAME=%1
  7. VBoxManage setextradata "%VMNAME%" "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVendor" "American Megatrends Inc"
  8. VBoxManage setextradata "%VMNAME%" "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVersion" "2.1.0"
  9. VBoxManage setextradata "%VMNAME%" "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVendor" "ASUSTek Computer"
  10. call:gen_random_string 9
  11. VBoxManage setextradata "%VMNAME%" "VBoxInternal/Devices/pcbios/0/Config/DmiSystemSerial" "string:!rand!"
  12. call:gen_random_string 20
  13. VBoxManage setextradata "%VMNAME%" "VBoxInternal/Devices/pcbios/0/Config/Port0/SerialNumber" "string:!rand!"
  14. call:gen_random_string 8
  15. VBoxManage setextradata "%VMNAME%" "VBoxInternal/Devices/pcbios/0/Port0/FirmwareRevision" "string:!rand!"
  16. VBoxManage setextradata "%VMNAME%" "VBoxInternal/Devices/pcbios/0/Port0/ModelNumber" "SEAGATE ST3750525AS"
  17. echo.
  18. echo Success!
  19. echo.
  20. pause
  21. goto:eof
  22. :usage
  23. echo Usage: %0 VM-Name
  24. echo This script shold be started from HOST machine
  25. echo where VM-name is a name of STOPPED VirtualBox virtual machine
  26. echo Note: the PATH variable must contain path to VBoxManage.exe
  27. echo like set PATH=C:\Program Files\Oracle\VirtualBox;%%PATH%%
  28. echo.
  29. pause
  30. goto:eof
  31. :gen_random_string
  32. set lineup=0123456789ABCDEF
  33. set RandomLength=%1
  34. set count=0
  35. set rand=
  36. :loop
  37. set /a count+=1
  38. set /a_RND=%Random%*15/32768
  39. set rand=!rand!!lineup:~%_RND%,1!
  40. if !count! lss %RandomLength% goto loop
  41. :eof
复制代码

作者: Batcher    时间: 2018-9-10 13:56

BAT是无法在Linux里面执行的,需要找个懂sh而且知道你想实现什么功能的人把代码重写一遍。
作者: ihubert    时间: 2018-9-10 16:48

我连现在的bat都没看太明白。。。




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2