當執行某個command時, 由該主程式檢查第1個參數名稱, 再執行相對應的動作
test.c
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[])
{
int i;
for (i=0;i<argc;++i) {
printf("%s ", argv[i]);
}
printf("\n");
if ( strstr(argv[0], "iamlink") ) {
printf("hello, link\n");
}
}
>gcc -o test test.c
>ln -sf test iamlink
>./iamlink
hello, link
No comments:
Post a Comment