I have a simple program test which gets a number as input and prints the same on console.
#include<stdio.h>
int main(void)
{
int i;
printf("Test Pgm \n");
printf("Enter a no:");
scanf("%d",&i);
printf("No Inputted:%d \n",i);
return 0;
}
//The above program lies on 10.220.5.xx (different machine)
##gcc -o test test.c
On invoking the test pgm frm another machine over ssh , I don’t get any prompt on the machine where im executing.
$ ssh user@10.220.3.xx '/home/user/test'
user@10.220.3.xx's password
After entering the password i don’t get see anything not even ‘Test Pgm’. How do i get the prompt remotely and input the values?
Try adding
fflush(stdout);before thescanf().Also, you must check the return value of
scanf(), it can fail to convert the input if given non-numerical text: