📄 count_nic.c
字号:
#include<stdio.h>#include<stdlib.h>#define P printf//------------------------------------------------------------------------------//Count the number of NICs on this Switch//------------------------------------------------------------------------------int count_nics(){ FILE * f_c; int count;//Count the number of device in the systemif(system("/sbin/ifconfig -a | grep \"^eth\" |wc -l > count_NIC_file")==-1){ P("Error when check those files!!\n"); P("Can not continue, please report this bug to truongbaolong@yahoo.com.\n"); P("Can not continue, please report this bug to truongbaolong@yahoo.com.\n");exit(1);}//P("Done.\n");f_c=fopen("count_NIC_file", "r");if(!f_c){ P("Can't generate temp file in local disk.\n"); P("Please report this bug to truongbaolong@yahoo.com.\n"); P("Can not continue.\n"); exit(1);}count=-1;fscanf(f_c, "%d", &count);if(count<2){ P("The switch must have at least 2 NICs.\n"); P("Can not continue..STOP!\n"); exit(0);}fclose(f_c);if(system("rm -f count_NIC_file")==-1){P("Error!\n");P("Cannot continue, please report to truongbaolong@yahoo.com\n");exit(1);}return count;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -