【问题标题】:Running unix checksum command in Python在 Python 中运行 unix 校验和命令
【发布时间】:2016-08-17 09:43:54
【问题描述】:

有没有我们可以在 Python 中运行下面的 unix 命令。

csum -h SHA1 <filename>

python 生成的校验和将被存储,并且应该与目标服务器中的 unix 命令生成的校验和匹配。
我知道我们可以通过 python 本身生成校验和。
但我不确定这是否与目标服务器上生成的 unix 校验和匹配。
所以我在想是否无论如何我们在两台服务器上运行相同的命令以确保不会因为 unix 和 python 而出现不匹配

【问题讨论】:

标签: python unix checksum


【解决方案1】:

你可以使用

import commands 
print commands.getstatusoutput('csum -h SHA1 foobar')
(0, 'YOURCHECKSUM')

请注意,commands 在 python 3 中已弃用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-07-03
    • 1970-01-01
    • 2016-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-24
    相关资源
    最近更新 更多