命令列標準

2021-06-20 06:55:58 字數 3960 閱讀 5916

1. 大寫字母

大寫字母表示該命令的該部分必須輸入乙個字串引數,例如命令:

epon loid loid<1-24> [password<1-12>]

unsigned char val[25] = ;

if(strlen(argv[0]) > 24)

if(2 == argc) }

sprintf(val, argv[0], strlen(argv[0]));

if(2 == argc)

unsigned char name[64]="\0";

if(strlen(argv[0]) > 64 || strlen(argv[0])<1 )

sprintf(name, argv[0], strlen(argv[0]))

2. a.b.c.d和a.b.c.d/m

ip address a.b.c.d a.b.c.d [a.b.c.d]

struct in_addr ip, msk, gw;

int has_gw = 0, ret, i;

inet_aton(argv[0], &ip);

inet_aton(argv[1], &msk);

if (argc > 2)

if ((inet_aton(argv[0], &ip) == 0) || !valid_ip(ip))

if ((inet_aton(argv[1], &msk) == 0) || !valid_subnet_mask(ip, msk))

if (has_gw)

}if((ip.s_addr==info.netif.ip.s_addr)&&( msk.s_addr==info.netif.subnet.s_addr)&&(0==has_gw))

if((ip.s_addr==info.netif.ip.s_addr)&&( msk.s_addr==info.netif.subnet.s_addr)

&&(1==has_gw)&&(gw.s_addr==info.netif.gateway.s_addr))

//end modify by zhouguanhua 2012-12-3 of epn204qid0008

memset(&ipc_set, 0, sizeof(ipc_network_t));

safe_strncpy(ipc_set.hostname, info.hostname, sizeof(ipc_set.hostname));

safe_strncpy(ipc_set.inte***ce_state, info.inte***ce_state, sizeof(ipc_set.inte***ce_state));

ipc_set.ip_proto = ip_proto_static;

ipc_set.netif.ip = ip;

ipc_set.netif.subnet = msk;

if (has_gw)

else

3. 圓括號()和豎直線 |

圓括號一般和豎直線配合使用。圓括號括起來的部分表示這部分命令有幾個用豎直線分隔開的可選項,您必須選擇其中一項。

if(strstr(enable_str, (char *)argv[0]))  

else if(strstr(disable_str, (char *)argv[0]))

else

注:在這種情況下,括號內的字元無論是大寫或是小寫,都是當做string處理的,並且還有一種處理方式如下

if (!strcmp(argv[0], "all"))

else

{}

不過這裡的強制轉換的具體作用還有待研究 

4. 中括號

中括號中的引數表示可輸入可不輸入。

已在2中舉例

5. 尖括號和數值範圍

尖括號和數值範圍表示輸入的引數的取值範圍在兩個數值之間的某個數

defun (mac_address_timer_aging,

mac_address_timer_aging_cmd,

"mac-address timer aging <45-458>",

"configure mac address\n"

"configure timer\n"

"global aging time\n"

"global aging time (second)")

else

memset(&info, 0, sizeof(info));

info.aging_time = aging_time;

}

6. 埠b:e

b表示開始埠,e表示結束埠

7. icmp型別t.c

t表示協議,c表示code

8. mac位址h.h.h

例如:1051.ed5a.034e

9. 小數點開頭 .

表示後面可以輸入多個引數

拓展1. 有如mac-address timeraging<45-458>和mac-address timerno-aging這樣成對出現的,可如下編寫

if(strstr(self->string, "no"))  

else

no**編寫舉例

defun (logging_host,

logging_host_cmd,

"syslog host a.b.c.d level <0-7>",

"commands of configure logging\n"

"setting of syslog host configuration\n"

"ip address format is a.b.c.d (where the log messages send)\n"

"specify logging level\n"

"0--emergenchy,1--alert,2--critical,3--error,4--warning,5--notice,6--informational,7--debug\n")

if(strstr(self->string, "no"))

else

safe_strncpy(info.syslog_ip, argv[0], sizeof(info.syslog_ip));

if (argc > 1)

}iret = ipc_set_syslog(&info);

if(ipc_status_ok != iret)

return cmd_success;

}alias (logging_host,

no_logging_host_cmd,

"no syslog host",

no_desc_str

"commands of configure logging\n"

"no send logging messages to remote host\n");

snmp (enable|disable)新增no命令的這種形式,**可如下編寫

int tem_port_id=0;//cpu口的id為0

u_int32_t port_flow_control ;

switch_template_t sttemplateset;

cvn_global_memset(&sttemplateset,0,sizeof(sttemplateset));

if(strstr(self->string, "no"))

else

else if(strstr("disable",(char *)argv[0]))

}

code

命令列 Git Bash命令列小結

展示當前完整路徑pwd 建立資料夾mkdir 建立檔案touch 刪除資料夾rm rf 刪除檔案rm 重新命名mv 展示當前路徑下檔案 除了隱藏檔案 ls 展示當前路徑下所有檔案ls a 展示當前路徑下所有檔案以及詳細資訊ls al 轉至某目錄cd 根目錄 上級目錄.當前目錄.檢視檔案cat 檔名稱...

git 命令列 和 cmd命令列

設定全域性使用者名稱 git config global user.name 區域性把global換成local 檢視全域性 git config global list 檢視git的狀態 git status 初始化 git into 名字 新增乙個檔案 git add readme.txt 刪除...

c mysql命令列 mysql 命令列工具

1 mysql命令選項 2 mysql命令 3 mysql日誌 4 mysql服務端幫助 5 執行mysql指令碼 6 使用技巧 mysql是乙個能夠編輯輸入行的簡單sql shell,支援互動式和非互動式訪問。使用互動式時,查詢結果以ascii表的格式展示。使用非互動式時,查詢結果以製表符分隔的格...