I want to pass some commands from my C program, Here is the sample program :
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main(){
FILE *ssh = popen("ssh [email protected]", "w");
pid_t pid;
pid = fork();
if(!ssh)
{
fprintf(stderr, "Could not open pipe for output.\n");
}
if (pid==0){
fprintf(stdout, "Child process properly created.\n");
fputs("user", ssh);
fputc('\n', ssh); // enter key
_exit(0);
}
fprintf(stdout, "Exit from child process.\n");
pclose(ssh);
return 0 ;
}
Now when I run this program, it asks for Password at command prompt something like this :
[email protected]'s password:
I want to pass password from my sample program, not from Command prompt. Could anyone please tell me how to do this in C, programmatically.
SSH is used only for example.It could be for other scenarios also.
Thanks, Yuvi
sshinterface I suggest you ask in superuser.com.