how to delete my file if exits in the remote server with paramiko?
水静流深
1248283536 at qq.com
Sun Dec 14 07:49:56 EST 2014
More information about the Python-list mailing list
Sun Dec 14 07:49:56 EST 2014
- Previous message (by thread): which is the right file path format in python3.4 ?
- Next message (by thread): how to delete my file if exits in the remote server with paramiko?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I want to delete the file "names.txt" if it exits in "/home/names.txt" in my remote vps server.
import paramiko
host = "vps ip"
port = 22
transport = paramiko.Transport((host, port))
password = "key"
username = "root"
transport.connect(username = username, password = password)
sftp = paramiko.SFTPClient.from_transport(transport)
if "names.txt" in sftp.listdir("/home") : sftp.remove("/home/names.txt")
Is there more elegant way to do the same work?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20141214/dfd18a51/attachment.html>
- Previous message (by thread): which is the right file path format in python3.4 ?
- Next message (by thread): how to delete my file if exits in the remote server with paramiko?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list