I want to execute the following command from my C program:
ssh -t -t root@192.168.3.21 "export LINES=40;export COLUMNS=124;export TERM=xterm;$SHELL -i" 0 < t_in 1 > t_out
If I am using system call as in:
system("ssh -t -t root@192.168.3.21 \"export LINES=40;export COLUMNS=124;export TERM=xterm;$SHELL -i\" 0<t_in 1>t_out");
that works fine. But I need to get the PID of the SSH process, so I have to use execlp.
What I tried so far is:
pid = fork();
if(pid == 0) {
fd_in = open("td_in", O_RDWR | O_NONBLOCK);
dup2(fd_in, 0);
close(fd_in);
fd_out = open("td_out", O_RDWR | O_NONBLOCK);
dup2(fd_out, 1);
close(fd_out);
execlp("ssh", "ssh", "-t", "-t", "root@192.168.3.21", "\"export LINES=40;export COLUMNS=124;export TERM=xterm;$SHELL -i\"", 0);
} else {
// not important here
}
When running this It goes to SSH login and after introducing password I get the error:
bash:export LINES=40;export COLUMNS=124;export TERM=xterm;/bin/bash -i: No such file or directory. Connection to 192.168.3.21 closed.
t_in and t_out are some fifo's (named pipes)
My question is what should be the correct execlp call to execute the above command. Thanks