最近在lamp下面开发php extension 需要经常重启apache 神马的 /etc/init.d/apache2 restart ,比较麻烦…..就写了个简单的工具
集合了一些常用的工具,命令… 为了更加非主流点 加了个随机每个字符串随机颜色(-_-) 其他以后有需要再往里面加吧
代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
* @id Ya-ya.cpp-1-2013-5-6
* @desc A convenient Linux toolbox
* @team UAUC Team WwW.UaUc.Net
* @author Yaseng WwW.Yaseng.Me [Yaseng@UAUC.NET]
*/
#include <iostream>
#include <string.h>
#include<stdlib.h>
#include <ctime>
using namespace std;

char *color[]={"&#92;&#48;33[0;31m","&#92;&#48;33[0;32m","&#92;&#48;33[0;33m","&#92;&#48;33[0;34m","&#92;&#48;33[0;35m","&#92;&#48;33[0;36m","&#92;&#48;33[0;37m","&#92;&#48;33[1;30m","&#92;&#48;33[1;31m","&#92;&#48;33[1;32m","&#92;&#48;33[1;33m","&#92;&#48;33[1;34m","&#92;&#48;33[1;35m","&#92;&#48;33[1;36m","&#92;&#48;33[1;37m","&#92;&#48;33[0m"}; //color array

void msg(char* msg,int type=1){

const char*f=type ? "[+]" : "[-]" ;
//cout << f;
srand( (unsigned)time( NULL ) );
for(int i=0;i<strlen(msg);i++){

int n;
n = rand() % 16;
cout<<color[n]<<msg[i];

}
cout<< endl;

}

int main(int argc,char* argv[]){

char* a=argv[1];
if(a==NULL){

msg("Hello Yaseng \nOption:apache => restart apache \n mysql => restart mysql \n www => cd /var/www/ directory \n eclipse=> start eclipse \n c:clear b:ping");

}else if(strcmp(a,"apache")==0){

msg("Ya:Apache Restarting");
system("/etc/init.d/apache2 restart");

}else if(strcmp(a,"www")==0){

msg("cd /var/www/ directory");
//system("cd /var/www/");
chdir("/var/www/");

}else if(strcmp(a,"mysql")==0){

msg("Ya:Mysql Restarting");
system("/etc/init.d/mysql restart");

}else if(strcmp(a,"eclipse")==0){

msg("Ya:Eclipse Starting");
system("/root/develop/eclipse/eclipse");

}else if(strcmp(a,"c")==0){

system("clear");

}else if(strcmp(a,"b")==0){

msg("Ya:Test Network");
system("ping -c 3 www.baidu.com");

}

return 0;
}

g++ 编译 g++ -o ya ya.cpp
然后把当 前路径加入环境变量
/root/.bashrc 加句 :export PATH=$PATH:/root/develop/project/ya/src
就可以随处使用了
上个图