2013-01-15 23 views
2
plink [email protected] -t '/home/user/test/testpgm' 

我可以使用上述plink cmd從windows計算機上運行駐留在Linux機器上的下面的程序。Plink傳遞參數

#include<stdio.h> 
int main(int argc,char *argv[]) 
{ 
    int i; 
    char buf[30]; 
    printf("Test Pgm \n"); 
    printf("No of Arguments=%d\n",argc); 
    printf("Enter a string:"); 
    fflush(stdout); 
    gets(buf); 
    printf("Input str:%s \n",buf); 

    return 0; 
} 

gcc test.c -o testpgm 

問題:如何將命令行參數傳遞給此函數? 我試圖

plink [email protected] -t '/home/user/test/testpgm arg1' 

bash: /home/user/test/testpgm arg1: No such file or directory 

回答

4

引號內shell對字符串作爲一個字,這意味着plink試圖執行該程序/home/user/test/testpgm arg1。顯然這是行不通的。

你要做的事很簡單:跳過引號!

$ plink [email protected] -t /home/user/test/testpgm arg1 
+0

謝謝。有用。 – m4n07