2014-11-21 110 views
0

我在写远程机器上的cli命令的服务器上写着shell script。 在我的问题远程机器是vmware vsphere client虚拟机。我知道虚拟机的细节,即ip address,等....我也知道所有的命令需要ran.manually我能够做到这一点,但我可以,同样可以编写linux shell脚本。 请注意两者都是Linux机器命令如何编写linux外壳脚本在cli上执行远程机器上的cli命令集从012开始

  • CLI

  • 配置

  • 组模块元件的

    列表

  • 组模块元件TenantInstance 1

  • 组模块元件TenantInstance 1属性customParameter1 “一些值”

  • 组模块元件TenantInstance 1属性customParameter2 “一些值”

  • 组模块元件TenantInstance 1属性customParameter3 “someValue中”

  • set模块元素TenantInstance 1 ExternalVlan 4094属性标签ISCSI-TRAFFIC

提交

确认

等等

任何人可以帮我如何写剧本先谢谢了!

回答

1

把所有的命令在shell脚本远程的vSphere机器上,在说/usr/local/bin/commands这样的:

#!/bin/bash 
export PATH=something 
configure 
set module element ... 
set Module Element TenantInstance 1 
... 

然后使脚本可执行,就像这样:

chmod +x /usr/local/bin/commands 

然后运行它使用这个命令在vspehere机器上本地运行,直到它全部工作:

/usr/local/bin/commands 

注意:如果您遇到的问题和需要调试脚本,因为它们扩大了第一行更改,以便查看相应的命令下,然后运行:

#!/bin/bash -xv 

简单地删除-xv当你完成调试。

最后,返回到服务器,然后从那里使用ssh这样的远程运行:

ssh vspehere_machine /usr/local/bin/commands 
相关问题