我正在比较来自远程计算机的 Python 中的两个文件的日期(如果从今天到昨天的最后修改时间是 24 小时):
我正在尝试通过这种方式:
commandcomp = 'echo `stat -c%Y /var/tmp/check_ipsleft/today.txt /var/tmp/check_ipsleft/yesterday.txt` | bc'
outputcomp = check_output(commandcomp, shell=True)
在本地计算机中,此命令有效:
`echo `stat -c%Y /var/tmp/check_ipsleft/today.txt /var/tmp/check_ipsleft/yesterday.txt` | bc`
/bin/sh: -c: línea 0: EOF inesperado mientras se buscaba un ``' coincidente
/bin/sh: -c: línea 1: error sintáctico: no se esperaba el final del fichero
Traceback (most recent call last):
File "checkipleft.py", line 46, in <module>
outputcomp = check_output(commandcomp, shell=True)
File "/opt/python-dsmc/lib/python2.7/subprocess.py", line 573, in check_output
raise CalledProcessError(retcode, cmd, output=output)
subprocess.CalledProcessError: Command 'echo "stat -c%Y `/var/tmp/check_ipsleft/today.txt" - "stat /var/tmp/check_ipsleft/yesterday.txt" | bc' returned non-zero exit status 1
慕的地10843
相关分类