Chinaunix首页 | 论坛 | 博客
  • 博客访问: 469996
  • 博文数量: 279
  • 博客积分: 4467
  • 博客等级: 上校
  • 技术积分: 2830
  • 用 户 组: 普通用户
  • 注册时间: 2007-04-03 14:43
文章分类

全部博文(279)

文章存档

2013年(1)

2012年(39)

2011年(35)

2009年(29)

2008年(131)

2007年(44)

分类:

2007-11-27 16:15:32

mail : 
The attachment files are the template file for blog site's
configuration and database schema.
Please help to write following program:
create_blog.pl


It will do following things:
- modified the file wp-config.php for these variable:
define('DB_NAME', 'uniforce_blog'); define('DB_USER', 'uniblogadmin');
define('DB_PASSWORD', '123uniforce');
- modified the file blog_db.sql by replace the url
to a new url.
将文件wp-config.php and blog_db.sql文件中的用户名和密码替换下来,以便可以在其它的地方能够通过参数直接使用。


#!/usr/bin/perl

#use warnings

use Tie::File;

sub blog{
#php

$phpfile=$directory.'wp-config.php';
#print "$phpfile\n";

open (CONFIG,$phpfile) or die "can't open wp-config.php$!\n";

foreach $_(<CONFIG>){
s/\'DB_NAME\',.*\)/\'DB_NAME\', \'$db_name\'\)/;
s/\'DB_USER\',.*\)/\'DB_USER\', \'$db_user\'\)/;
s/\'DB_PASSWORD\',.*\)/\'DB_PASSWORD\', \'$db_passwd\'\)/;

#print "$_\n";
`echo "$_">>blog1`;
}
`rm -rf $phpfile`;
`mv blog1 $phpfile`;

#sql
$datafile=$directory.'
blog_db.sql';


    tie my @lines, '
Tie::File', $datafile or die "Cannot open $datafile: $!\n";
   
    my $url_old = '
http://b2k.uniforce.net

阅读(258) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~