找出linux系统没有的补丁
时间:2009-03-23 来源:sjhf
同学先用了一个perl程序,把ftp.kernl.org上的补丁目录读取在一个文件list中,然后我用了shell把没有打的补丁找出。^_^开始时是用C写的,感觉比较麻烦,于是就边看shell边写了下这个 ========================================= perl程序如下: #!/usr/bin/perl use Net::FTP; my $host="www.kernel.org"; my $directory = "pub/linux/kernel/v2.6"; $ftp = Net::FTP->new($host,Timeout=>240) or $newerr = 1; push @ERRORS, "Can't connect to ftp $host: $!\n" if $newerr; myerr() if $newerr; print "Connected\n"; $ftp->login("anonymous","[email protected]") or $newerr = 1; print "Getting file list\n"; push @ERRORS, "Can't login to $host: $!\n" if $newerr; $ftp->quit if $newerr; myerr() if $newerr; print "Logged in\n"; $ftp->cwd($directory) or $newerr=1; push @ERRORS, "Can't cd $!\n" if $newerr; myerr() if $newerr; $ftp->quit if $newerr; open (DIRC,">list") or die "$!\n"; @files = $ftp->dir or $newerr = 1; push @ERRORS, "Can't get file list $!\n" if newerr; print "Got file list\n"; foreach(@files){ if ($_ =~ /patch/ && $_ !~ /sign/ && $_ !~ /gz/){ print DIRC "$_\n"; } } $ftp->quit; sub myerr{ print "Error: \n"; print @ERRORS; exit 0; } ========================================= shell程序如下: #!/bin/bash clear awk '{print $9}' list > newList grep 'patch\-2\.[0-9]\.[0-9][0-9]*\.bz2' newList > new_list_test awk '{print substr($1,7,99)}' new_list_test > near_final uname -r | tr - '\n' > getKernelType exec 4<&0 0< getKernelType read nowType nowType=$nowType".bz2" #echo $nowType #line_num=`wc -l near_final | awk '{print $1}'` #echo $line_num for i in `cat near_final` do line=$i if [ $nowType \< $line ] then echo $line fi done |
相关阅读 更多 +
排行榜 更多 +