2005年02月28日 星期一 18:32
自动检查md5sums:
////////////////////////////////////////////////////////////////////////////////////////////////
#! /usr/local/bin/python
import commands
file = raw_input("Enter the filename: ")
sum = raw_input("Enter the md5sum: ")
md = "md5sum " + file
print md
check = str(commands.getoutput(md))
checksum = sum + " " + file
#print checksum
print check
if check == checksum: print "Sums OK"
else: print "Sums are not the same!"
///////////////////////////////////////////////////////////////////////////////////////////////////
上网看到的code,检查md5sums。有什么想法?大家有没有更好的办法?(using
command line)
//////////////////////////////////////////////////////////////////////////////////////////////////
小弟仍然在学习中,但觉得上面的code不错,而且用起来没见到有什么问题。
/////////////////////
// //
// 菜鸟笔记 //
// http://linux.99blog.com //
// //
////////////////////
2005年02月28日 星期一 20:56
python有md5模块啊,为什么不用? 当然,采用commands模块调用外部程序也没什么不可以的,就是要冒安全性风险,比如用户在Enter the md5sum:时输入"********; rm -rf /",碰巧又是以root权限在执行,就等着哭吧。 因此需要调用外部程序时,commands, system等方法都是需要再三考虑安全性问题的。 On Mon, 28 Feb 2005 10:32:15 +0000, steve <lau.siyuan at gmail.com> wrote: > 自动检查md5sums: > > //////////////////////////////////////////////////////////////////////////////////////////////// > #! /usr/local/bin/python > import commands > file = raw_input("Enter the filename: ") > sum = raw_input("Enter the md5sum: ") > md = "md5sum " + file > print md > check = str(commands.getoutput(md)) > checksum = sum + " " + file > #print checksum > print check > if check == checksum: print "Sums OK" > else: print "Sums are not the same!" > /////////////////////////////////////////////////////////////////////////////////////////////////// > > 上网看到的code,检查md5sums。有什么想法?大家有没有更好的办法?(using > command line) > > ////////////////////////////////////////////////////////////////////////////////////////////////// > > 小弟仍然在学习中,但觉得上面的code不错,而且用起来没见到有什么问题。 > > ///////////////////// > // // > // 菜鸟笔记 // > // http://linux.99blog.com // > // // > //////////////////// > _______________________________________________ > python-chinese list > python-chinese at lists.python.cn > http://python.cn/mailman/listinfo/python-chinese > -- Get Firefox! http://www.spreadfirefox.com/?q=affiliates&id=67907&t=1
2005年02月28日 星期一 22:29
Qiangning Hong wrote: >python有md5模块啊,为什么不用? > >当然,采用commands模块调用外部程序也没什么不可以的,就是要冒安全性风险,比如用户在Enter the >md5sum:时输入"********; rm -rf /",碰巧又是以root权限在执行,就等着哭吧。 > >因此需要调用外部程序时,commands, system等方法都是需要再三考虑安全性问题的。 > > >On Mon, 28 Feb 2005 10:32:15 +0000, steve <lau.siyuan at gmail.com> wrote: > > >>自动检查md5sums: >> >>//////////////////////////////////////////////////////////////////////////////////////////////// >>#! /usr/local/bin/python >>import commands >>file = raw_input("Enter the filename: ") >>sum = raw_input("Enter the md5sum: ") >>md = "md5sum " + file >>print md >>check = str(commands.getoutput(md)) >>checksum = sum + " " + file >>#print checksum >>print check >>if check == checksum: print "Sums OK" >>else: print "Sums are not the same!" >>/////////////////////////////////////////////////////////////////////////////////////////////////// >> >>上网看到的code,检查md5sums。有什么想法?大家有没有更好的办法?(using >>command line) >> >>////////////////////////////////////////////////////////////////////////////////////////////////// >> >>小弟仍然在学习中,但觉得上面的code不错,而且用起来没见到有什么问题。 >> >>///////////////////// >>// // >>// 菜鸟笔记 // >>// http://linux.99blog.com // >>// // >>//////////////////// >>_______________________________________________ >>python-chinese list >>python-chinese at lists.python.cn >>http://python.cn/mailman/listinfo/python-chinese >> >> >> > > > > 太谢谢了!这样看起来这样做是有些多此一举了
Zeuux © 2025
京ICP备05028076号