I need to test if a series of applications is installed in a linux/unix based host and in a windows host. So obviously, in unix/linux is as easy as ssh-ing the host an run $ which $cmd
like:
我需要测试一系列应用程序是否安装在基于linux / unix的主机和Windows主机中。所以很明显,在unix / linux中就像ssh-ing主机一样简单运行$ which cmd就像:
def valid_util?(cmd, user, host, pass)
begin
result = nil
Timeout::timeout(10) do
Net::SSH.start( host.to_s, user.to_s, :password => pass.to_s) do |ssh|
result = ssh.exec!(cmd.to_s)
end
end
rescue Timeout::Error
raise TimeoutError, 'SSH connection timeout!'
end
!result.nil?
end
How can I achieve something similar in windows? Can anyone help me figuring this out?
如何在Windows中实现类似的功能?任何人都可以帮我解决这个问题吗?
1 个解决方案
#1
0
@skimisha
Hmm, maybe this approach would help:
嗯,也许这种方法会有所帮助:
- Use samba to connect to windows from linux (you can use ruby/SMB).
- Once connected, you may use samba to browse the server and then based on results locally assert if the applications in questions have been installed.
使用samba从linux连接到windows(你可以使用ruby / SMB)。
连接后,您可以使用samba浏览服务器,然后根据结果本地断言是否已安装问题中的应用程序。
BUT, if your use case is bit more complex (e.g. checking windows registry, etc.) and you must fire-off a command to check (similar to what you are doing against linux remote hosts), you may:
但是,如果您的用例有点复杂(例如,检查Windows注册表等),您必须启动一个命令来检查(类似于您对Linux远程主机的操作),您可以:
- setup ssh on windows using cygwin and then remotely execute .bat or .cmd files.
- try using winexe
使用cygwin在Windows上设置ssh,然后远程执行.bat或.cmd文件。
尝试使用winexe
#1
0
@skimisha
Hmm, maybe this approach would help:
嗯,也许这种方法会有所帮助:
- Use samba to connect to windows from linux (you can use ruby/SMB).
- Once connected, you may use samba to browse the server and then based on results locally assert if the applications in questions have been installed.
使用samba从linux连接到windows(你可以使用ruby / SMB)。
连接后,您可以使用samba浏览服务器,然后根据结果本地断言是否已安装问题中的应用程序。
BUT, if your use case is bit more complex (e.g. checking windows registry, etc.) and you must fire-off a command to check (similar to what you are doing against linux remote hosts), you may:
但是,如果您的用例有点复杂(例如,检查Windows注册表等),您必须启动一个命令来检查(类似于您对Linux远程主机的操作),您可以:
- setup ssh on windows using cygwin and then remotely execute .bat or .cmd files.
- try using winexe
使用cygwin在Windows上设置ssh,然后远程执行.bat或.cmd文件。
尝试使用winexe