Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect("10.9.8.7", username="fakeuser", password="fakepasswd")
- log_path = "D:\Log"
- if_exist_path = "cmd /c if exist "" + log_path + "" echo Exists"
- print("Var 'if_path_exist' is: {}".format(if_exist_path))
- stdin, stdout, stderr = ssh.exec_command(if_exist_path)
- stdoutput = stdout.readlines()
- stderror = stderr.readlines()
- print("First Stdout is {}".format(stdoutput))
- print("First Stderr is {}".format(stderror))
- print("")
- stdin, stdout, stderr = ssh.exec_command('cmd /c dir "D:\Log"')
- stdoutput = stdout.read()
- stderror = stderr.read()
- print("Second Stdout is {}".format(stdoutput))
- print("Second Stderr is {}".format(stderror))
- C:Scripts>SO_Test.py
- Var 'if_path_exist' is: cmd /c if exist "D:Log" echo Exists
- First Stdout is []
- First Stderr is []
- Second Stdout is Volume in drive D is Apps
- Volume Serial Number is xxxx-xxxx
- Directory of D:
- Second Stderr is File Not Found
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement