3
plink user@10.220.60.xx -t '/home/user/test/testpgm'

我可以使用上面的 plink cmd 从 Windows 机器上运行以下驻留在 Linux 机器上的程序。

#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 user@10.220.60.xx -t '/home/user/test/testpgm arg1'

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

2 回答 2

5

shell 将引号内的字符串视为一个单词,这意味着plink尝试执行程序/home/user/test/testpgm arg1。显然这行不通。

你要做的很简单:跳过引号!

$ plink user@10.220.60.xx -t /home/user/test/testpgm arg1
于 2013-01-15T08:39:13.663 回答
0

我试过

plink user@10.220.60.xx /home/user/test/testpgm arg1

工作正常。

于 2013-01-15T08:40:29.207 回答