Вот вся моя прога
ЗЫ: Я только начинаю с с++
Еще такая проблема - если запрос ничего не вернул прога возвращает - Ошибка сегментирования
За кодом примерint
main(int argc, char *argv[])
{
string ip_argv;
ip_argv=argv[1];
mysqlpp::Connection con(false);
con.connect(MY_DATABASE, MY_HOST, MY_USER, MY_PASSWORD);
mysqlpp::Query query = con.query();
query << "SELECT `ip` AS ip, `group` AS g,`num` AS n,`bw_in` AS in_,`bw_in_name` AS in_n,`bw_out` AS out_,`bw_out_name` AS out_n,`n_pipe_in` AS p_in,`n_pipe_out` AS p_out,`hour` AS h_,`activ` AS e,`id` AS `id`,`num2` AS n1 FROM "<<" "<< TABLE_DEFAULT <<" "<<" WHERE ip='"<< ip_argv<<"' AND activ='y'";
mysqlpp::ResUse res = query.use();
if (res) {
cout.setf(ios::left);
mysqlpp::Row row;
while (row = res.fetch_row()) {;}
string ip,g,n,n1,bw_in,bw_in_name,bw_out,bw_out_name,n_pipe_in,n_pipe_out,hour,activ,id;
ip=row.raw_data(0);
g=row.raw_data(1);
n=row.raw_data(2);
bw_in=row.raw_data(3);
bw_in_name=row.raw_data(4);
bw_out=row.raw_data(5);
bw_out_name=row.raw_data(6);
n_pipe_in=row.raw_data(7);
n_pipe_out=row.raw_data(8);
hour=row.raw_data(9);
activ=row.raw_data(10);
n1=row.raw_data(11);
string exec_this="";
exec_this="/sbin/pfctl -t inat -Tadd "+ip+";";
exec_this +="/sbin/ipfw delete "+n+"; ";
exec_this +="/sbin/ipfw add "+n+" pipe "+n_pipe_out+" all from not 10.0.0.0/8 to "+ip+" out;";
exec_this +="/sbin/ipfw add "+n1+" pipe "+n_pipe_in+" all from "+ip+" to not 10.0.0.0/8 to in";
char ecc[4000];
strcpy(ecc,exec_this.c_str());
cout <<" "<<ecc;
system(ecc);
return 0;
}
else {
cout <<"database server DOWN"<<endl;
return 1;
}
}
---------------------------------------------------
#./simple1 192.168.0.3
----Это вывод---
/sbin/pfctl -t inat -Tadd 192.168.0.3;/sbin/ipfw delete 500; /sbin/ipfw add 500 pipe 0 all from not 10.0.0.0/8 to 192.168.0.3 out;/sbin/ipfw add 500 pipe Kbit/s all from 192.168.0.3 to not 10.0.0.0/8 to in
# ./simple1 192.168.0.1
----Это вывод---
Ошибка сегментирования