Plink传递参数

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

我能使用上述plink命令从Windows机器运行以下程序,该程序位于Linux机器上。请注意,保留了HTML标签。
我可以通过上述plink命令从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
2个回答

5

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

你需要做的非常简单:跳过引号!

$ plink user@10.220.60.xx -t /home/user/test/testpgm arg1

0

我尝试过

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

运行良好。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接