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

On running the below program which resides on a Linux machine from a windows machine using plink, I get only the following messages.

Test Pgm
Enter a string:

On Entering a string as input, It doesn't appear in the command window and the output as well doesn't appear.

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

   return 0;
}

gcc test.c -o testpgm

PS:Plink (PuTTY Link) is a command-line connection tool similar to UNIX ssh.

m4n07
  • 2,267
  • 12
  • 50
  • 65
  • have you tried adding a `fflush(stdout)` call after printf? maybe the plink connection gets closed before the output is flushed correctly. – Andreas Grapentin Jan 11 '13 at 12:00
  • I tried fflush(stdout) at the end ,Its not working. – m4n07 Jan 11 '13 at 12:11
  • On changing the gets(buf) to scanf("%s",buf) , It works partially. What ever i input i can see it as output. But I'm not able to see what i'm inputting. – m4n07 Jan 11 '13 at 12:26
  • 1
    okay, try adding a `-t` to your plink call. Plink is not intended to be used with interactive sessions, like you use it. have a look at this: http://the.earth.li/~sgtatham/putty/0.58/htmldoc/Chapter7.html especially the line "Plink is probably not what you want if you want to run an interactive session in a console window. " – Andreas Grapentin Jan 11 '13 at 12:27
  • Thank you Andreas! It works on adding -t. If you are aware of any alternatives please let me know. – m4n07 Jan 11 '13 at 12:32
  • openssh would be good, I think. I'll put my thoughts and ideas in an answer. – Andreas Grapentin Jan 11 '13 at 12:33

2 Answers2

1

Plinks documentation1 suggests, that you should not use Plink for interactive shell sessions, like you normally do with ssh, but for automated tasks instead. However, if you pass the -t parameter to your plink call, you can give it some interactive behaviour (with limitations).

some other alternatives to ssh in a windows environment are:

freeSSHd (provided by Microsoft) http://www.freesshd.com/

openSSH http://www.openssh.com/

dropbear https://matt.ucc.asn.au/dropbear/dropbear.html

I've tested none of these, but I think you'll figure it out :)

Andreas Grapentin
  • 5,499
  • 4
  • 39
  • 57
1

It might not be useful for this scenario but to disable interactive prompts and to auto-accept the ssh handshake, you can use below mentioned options when trying to get into a server and executing commands using Plink.

plink -batch -v username@hostname -pw password -m shell.sh

Where: -batch (disable all prompts)

echo y | plink -ssh username@hostname -pw password -m commands.txt
Alok Tiwari
  • 354
  • 3
  • 8