说,我有一个用这行调用的脚本:
./myscript -vfd ./foo/bar/someFile -o /fizz/someOtherFile
Run Code Online (Sandbox Code Playgroud)
或者这个:
./myscript -v -f -d -o /fizz/someOtherFile ./foo/bar/someFile
Run Code Online (Sandbox Code Playgroud)
什么是分析这使得在每一种情况下(或两者的组合)的接受的方式$v,$f以及 $d将全部设置为true和$outFile将等于/fizz/someOtherFile?
如何做os.walk(),而是通过SSH在另一台计算机上?问题是它os.walk()在本地机器上执行,我想通过 ssh 连接到另一台名为“sunbeam”的计算机,遍历一个目录并为其中的每个文件生成 MD5 哈希值。
到目前为止我写的看起来像这样(下面的代码),但它不起作用。任何帮助将不胜感激。
try:
hash_array = []
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('sunbeam', port=22, username='xxxx', password='filmlight')
spinner.start()
for root, dirs, files in os.walk(_path):
for file in files:
file_path = os.path.join(os.path.abspath(root), file)
# generate hash code for file
hash_array.append(genMD5hash(file_path))
file_nb += 1
spinner.stop()
spinner.ok('Finished.')
return hash_array
except Exception as e:
print(e)
return None
finally:
ssh.close()
Run Code Online (Sandbox Code Playgroud)