简体   繁体   English

检查文件是否存在,如果为真则打开 SFTP

[英]Check if file exist if true then open SFTP

First time using this website, i have a challenge now with one of our clients that they are blocking our SFTP account if we connect and do not send any file.第一次使用这个网站,我现在对我们的一位客户提出挑战,如果我们连接并且不发送任何文件,他们会阻止我们的 SFTP 帐户。 Something that i am looking for is a script for powershell or could be anything that i can build into.exe file with visual studio so that the script firstly would check:我正在寻找的东西是 powershell 的脚本,或者可以是我可以使用 visual studio 构建到 .exe 文件中的任何东西,以便脚本首先检查:

Check if file exists If False then stop If true open sftp and send the file检查文件是否存在如果为假则停止如果为真打开sftp并发送文件

any help would be trully appreciated!任何帮助将不胜感激!

You can use a try-except block to figure out if the file is open您可以使用 try-except 块来确定文件是否打开

try:
    file = open("Your file's location",'r')
except:
    pass
else:
    # Everything else goes here #
    file.close()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM