Paramikoを使用してすでに接続しているリモートサーバー上の特定のディレクトリ内のすべてのファイルを削除したいと思います。ただし、ファイル名は、以前に配置したファイルのバージョンによって異なるため、明示的に指定することはできません。
これが私がやろうとしていることです...#TODOの下の行は、私が試している呼び出しですremoteArtifactPath
。/opt/foo/*
ssh = paramiko.SSHClient()
ssh.load_host_keys(os.path.expanduser(os.path.join("~", ".ssh", "known_hosts")))
ssh.connect(server, username=username, pkey=mykey)
sftp = ssh.open_sftp()
# TODO: Need to somehow delete all files in remoteArtifactPath remotely
sftp.remove(remoteArtifactPath+"*")
# Close to end
sftp.close()
ssh.close()
どうすればこれを達成できるか考えていますか?