Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82501
| From | "水静流深" <1248283536@qq.com> |
|---|---|
| Subject | how to delete my file if exits in the remote server with paramiko? |
| Date | 2014-12-14 20:49 +0800 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16944.1418561416.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
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?
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
how to delete my file if exits in the remote server with paramiko? "水静流深" <1248283536@qq.com> - 2014-12-14 20:49 +0800 Re: how to delete my file if exits in the remote server with paramiko? Roy Smith <roy@panix.com> - 2014-12-14 10:58 -0500
csiph-web