发布时间:2019-09-11 07:46:27编辑:auto阅读(3367)
1.
cmd = "some unix command" retcode = subprocess.call(cmd,shell=True)
2.
ssh = paramiko.SSHClient() ssh.connect(server, username=username, password=password) ssh_stdin, ssh_stdout, ssh_stderr = ssh.exec_command(cmd_to_execute)
3.
import commands
command = "nslookup " + node + " | grep Name -1 | grep Address| awk '{print $2}'"
result = commands.getoutput(command)
if (result == ""):
return "unknown"4.
sshProcess = subprocess.Popen(['ssh', <remote client>], ,stdin=subprocess.PIPE, stdout = subprocess.PIPE)
sshProcess.stdin.write("ls mydirectory\n")
sshProcess.stdin.write("echo END\n")
for line in stdout.readlines():
if line == "END\n":
break
print(line)
sshProcess.stdin.write("uptime\n")
sshProcess.stdin.write("echo END\n")
for line in stdout.readlines():
if line == "END\n":
break
print(line)
上一篇: python split多个分隔符
下一篇: python 基础 数据类型
54096
40852
35364
31018
25910
25647
24085
19620
15690
15172
1911°
1752°
1844°
1925°
1921°
2100°
2054°
1873°
1959°
1940°