Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plink passing arguments

Tags:

c

linux

ssh

plink

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

I'm able to run the below program which resides on a Linux machine from a windows machine using the above plink cmd.

#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

Question: How to pass command line arguments to this function? I tried

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

bash: /home/user/test/testpgm arg1: No such file or directory
like image 442
m4n07 Avatar asked Mar 14 '26 17:03

m4n07


1 Answers

The shell treats strings inside quotes as a single word, which means that plink tries to execute the program /home/user/test/testpgm arg1. Obviously this won't work.

What you have to do is very simple: Skip the quotes!

$ plink [email protected] -t /home/user/test/testpgm arg1
like image 159
Some programmer dude Avatar answered Mar 16 '26 07:03

Some programmer dude



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!