html link 加载图片,在index.html 里为每个link 加入图片

这个Perl脚本用于从master.html生成一个包含所有day.png链接的index.html。它检查命令行参数,删除旧的index.html(如果存在),然后读取master.html的内容,将HTTP-EQUIV="Expires"行替换,并在找到特定模式时更新链接。
摘要由CSDN通过智能技术生成

#!/usr/bin/perl -w

#maintained by bo.zhang@lsi.com

#version 1.0

#2012/09/08

#This script is to create a index.html that have every links day.png graph

#

print "we are going to use the master.html and create a new index\n";

print "we will add day.png for every link\n";

my $argv = @ARGV;

print @ARGV,"\n";

print $argv,"\n";

if ( $argv != 1 ){

print  "Usage    $0 \n";

print  "example  $0 cisr1.lsi.com\n";

print  "route maust be cisr1.lsi.com,only typing cisr1 will not working\n";

exit;

}

#

#

if ( -f "/var/www/html/mrtg/$ARGV[0]/index.html" ){

unlink("/var/www/html/mrtg/$ARGV[0]/index.html");

print "removed the file /var/www/html/mrtg/$ARGV[0]/index.html\n";

}

my $diag_dir = "/var/www/html/mrtg/$ARGV[0]/master.html";

#my $out_dir ="/work/mrtg.txt";

#opendir DH , $diag_dir or die "Can not open $diag_dir: $!";

open ON , $diag_dir or die "cannot open $diag_dir:$!";

my $table_value=0;

while (){

# print "$_";

open (FILE,">>/var/www/html/mrtg/$ARGV[0]/index.html");

syswrite(FILE,$_);

close FILE;

if (/HTTP-EQUIV="Expires"/){

open (HTML,">>/var/www/html/mrtg/$ARGV[0]/index.html");

print HTML << "TEXT";

TEXT

close HTML;

}

if (/^\

$table_value = $table_value +1;

print $_;

print "\n","my talbe value is",$table_value,"\n";

}

if ( $table_value==2){

#print "Hello it works.\n";

if ( $_ =~ /$ARGV[0]_(\d*).html/){

#print $ARGV[0];

# $& is the who match pattern (\d*) match digital like:1 2 12 123 12345 ...

#here like we need to make cisr1.lsi.com

#$& is cisr1.lsi.com_1.html  $1 here is (\d*) digitals 1,

print $&; print $1;

open (HTML,">>/var/www/html/mrtg/$ARGV[0]/index.html");

print HTML <

day

TEXT

close HTML;

}

}

}

close ON;

print "done :)\n "

# #system() executes the external command after forking a separate process, and the main program waits for the child process to complete before continuing. exec() however, *never* returns so is used when you�e finished with the original program. For both of these commands it is more efficient, and secure, to use the list form when passing arguments: # #system "/path/to/my/program.pl", $foo, $bar; # #instead of: # # #system "/path/to/my/program.pl $foo $bar";

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值