
常用函数API
HideOnLie
这个作者很懒,什么都没留下…
展开
-
system——执行指定命令或脚本
例:status = system("./test.sh"); 1、先统一两个说法:(1)system返回值:指调用system函数后的返回值,比如上例中status为system返回值(2)shell返回值:指system所调用的shell命令的返回值,比如上例中,test.sh中返回的值为shell返回值。2、如何正确判断test.sh是否正确执行?仅判断status是否==0?或者仅判断status是否!=-1?都错!3、man中对于system的说明RETURN VALUET转载 2020-07-13 11:20:43 · 1142 阅读 · 0 评论 -
执行Shell命令与获取命令结果的方法
目录简介1. system2. exec函数簇3. popen()和pclose()无名管道参考简介可以执行shell命令的函数:system()exec()popen()可以获取命令执行结果的方法:popen()无名管道1. systemNAME system - execute a shell commandSYNOPSIS #include <stdlib.h> int system(const char *comma转载 2020-06-05 12:06:51 · 1750 阅读 · 0 评论 -
if_nametoindex, if_indextoname——网络接口名与索引值之间的映射
说明NAME if_nametoindex, if_indextoname - mappings between network interface names and indexesSYNOPSIS #include <net/if.h> unsigned int if_nametoindex(const char *ifname); char *if_indextoname(unsigned int ifindex, char原创 2020-05-22 18:21:43 · 5402 阅读 · 0 评论 -
syscall——使用系统调用
目录函数说明参考函数说明NAME syscall - indirect system callSYNOPSIS #define _GNU_SOURCE /* See feature_test_macros(7) */ #include <unistd.h> #include <sys/syscall.h> /* For SYS_xxx definitions */ long sysc原创 2020-05-22 15:08:37 · 1109 阅读 · 0 评论 -
getopt——解析命令行选项
目录函数说明外部全局变量说明参考函数说明NAME getopt, getopt_long, getopt_long_only, optarg, optind, opterr, optopt - Parse command-line optionsSYNOPSIS #include <unistd.h> int getopt(int argc, char * const argv[], const char *原创 2020-05-21 16:02:45 · 194 阅读 · 0 评论