Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stdin, stdout, stderr = ssh.exec_command('cmd /c dir "D:"')
- stdin, stdout, stderr = ssh.exec_command('if [[ -d /cygdrive/d/log ]]; then echo Exists; fi')
- if_exist_path = "cmd /c if exist "" + log_path + "" echo Exists"
- stdin, stdout, stderr = ssh.exec_command(if_exist_path)
- import paramiko
- ssh = paramiko.SSHClient()
- ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
- ssh.connect("10.9.8.7", username="FakeUser", password="FakePassword")
- 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))
- print("")
- stdin, stdout, stderr = ssh.exec_command('cmd /c dir "D:"')
- stdoutput = stdout.read()
- stderror = stderr.read()
- print("Third Stdout is {}".format(stdoutput))
- print("Third Stderr is {}".format(stderror))
- print("")
- stdin, stdout, stderr = ssh.exec_command('cmd /c dir "D:\"')
- stdoutput = stdout.read()
- stderror = stderr.read()
- print("Fourth Stdout is {}".format(stdoutput))
- print("Fourth Stderr is {}".format(stderror))
- print("")
- stdin, stdout, stderr = ssh.exec_command('cmd /c dir "D:Log"')
- stdoutput = stdout.read()
- stderror = stderr.read()
- print("Fifth Stdout is {}".format(stdoutput))
- print("Fifth Stderr is {}".format(stderror))
- print("")
- stdin, stdout, stderr = ssh.exec_command('cmd /c dir "D:Log"')
- stdoutput = stdout.read()
- stderror = stderr.read()
- print("Sixth Stdout is {}".format(stdoutput))
- print("Sixth Stderr is {}".format(stderror))
- print("")
- 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
- Third Stdout is Volume in drive D is Apps
- Volume Serial Number is xxxx-xxxx
- Directory of D:
- 01/26/2017 10:49 PM <DIR> Log
- 01/12/2017 11:34 AM 12,887 Blah.ps1
- 01/12/2017 01:16 PM 12,082 result.txt
- 12/12/2016 03:39 PM 23,340 Blahv201.zip
- 04/15/2017 10:37 PM <DIR> Company
- 01/27/2017 08:19 PM <DIR> CompanyBackup
- 01/12/2017 01:08 PM 10,060 Untitled1.ps1
- 4 File(s) 58,369 bytes
- 3 Dir(s) 175,276,904,448 bytes free
- Third Stderr is
- Fourth Stdout is
- Fourth Stderr is sh: -c: line 0: unexpected EOF while looking for matching `"'
- sh: -c: line 1: syntax error: unexpected end of file
- Fifth Stdout is Volume in drive D is Apps
- Volume Serial Number is xxxx-xxxx
- Directory of D:
- Fifth Stderr is File Not Found
- Sixth Stdout is Volume in drive D is Apps
- Volume Serial Number is xxxx-xxxx
- Directory of D:
- Sixth Stderr is File Not Found
- if os.path.isdir("/test/to/dir") == True:
- print('dir exists ')
- # you next actions
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement