[英]remote powershell scripts on windows not running through python script in linux
我有一个使用paramiko和pysphere编写的python脚本。这个脚本在linnux box.i在windows机器上有一些powershell脚本,我必须一个接一个地运行(在每个脚本显然结束之后),但这里的重点是通过我的pythonscript它没有在Windows机器上运行powershell脚本。请帮助。 PS;我必须在windows上运行python脚本fromlinux和powershell scriupts。 以下是运行powershell脚本的代码片段:
target_vm1 = connect_Esxi_Server(return_list[0])
print "Again connected to vm:" + return_list[0]
target_vm1.login_in_guest(vmUser,vmPass)
list_scripts = target_vm1.list_files(VM_SCRIPT_LOCATION)
for f in list_scripts:
size = f['size']
**if size <> 0:**
paths = f['path']
print paths
#for all_scripts in paths:
*****print "script running is :" , paths*****
path_l = os.path.join(VM_SCRIPT_LOCATION + '\\'+ paths)
*****print path_l*****
run_script =
subprocess.Popen([r'c:\\Windows\\system32\\WindowsPowerShell\\v1.0\\powershell.exe',". path_l"], shell=True)
result = run_script.wait()
print "result is:", result
我怀疑子进程是否有效。
请注意,上面给出的粗体打印正在运行正确的脚本。在fo; der中有许多powershell脚本,因此循环遍历它并运行它们中的每一个。
任何帮助将不胜感激,这件事正在吃我的头..... argghhhhhhhh ..
干杯,新泽西州
我使用paramiko直接运行powershell命令:
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('10.10.0.2', username='vipul', password='password')
cmd = "powershell -InputFormat none -OutputFormat text echo Hello"
stdin, stdout, stderr = self.ssh.exec_command(cmd)
print stdout.readlines()
这里10.10.0.2是我的Windows机器。 使用cygwin sshd服务器进行ssh。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.