from stat import S_ISDIR
def isdir(path):
try:
return S_ISDIR(sftp.stat(path).st_mode)
except IOError:
#Path does not exist, so by definition not a directory
return False
…assuming sftp
is an open Paramiko SFTP connection.
More Related Contents:
- How to scp in Python?
- Is there a simple way to get rid of junk values that come when you SSH using Python’s Paramiko library and fetch output from CLI of a remote machine?
- Some Unix commands fail with ” not found”, when executed using Python Paramiko exec_command
- Environment variable differences when using Paramiko
- Pass input/variables to command/script over SSH using Python Paramiko
- How to use Paramiko logging?
- Paramiko ssh die/hang with big output
- Nested SSH using Python Paramiko
- Running interactive commands in Paramiko
- Executing command using Paramiko exec_command on device is not working
- What is the difference between exec_command and send with invoke_shell() on Paramiko?
- Reading file opened with Python Paramiko SFTPClient.open method is slow
- Command executed with Paramiko does not produce any output
- Read a file from server with SSH using Python
- Port forwarding with Paramiko
- How to list all the folders and files in the directory after connecting through SFTP in Python
- Running Sudo Command with paramiko
- Run multiple commands in different SSH servers in parallel using Python Paramiko
- Password authentication in Python Paramiko fails, but same credentials work in SSH/SFTP client
- Executing command using “su -l” in SSH using Python
- Execute command and wait for it to finish with Python Paramiko
- Implement an interactive shell over ssh in Python using Paramiko?
- How to run sudo with Paramiko? (Python)
- Paramiko authentication fails with “Agreed upon ‘rsa-sha2-512’ pubkey algorithm” (and “unsupported public key algorithm: rsa-sha2-512” in sshd log)
- How to create a SSH tunnel using Python and Paramiko?
- Paramiko: read from standard output of remotely executed command
- “Failed to load HostKeys” warning while connecting to SFTP server with pysftp
- How can you get the SSH return code using Paramiko?
- List files on SFTP server matching wildcard in Python using Paramiko
- python paramiko ssh