Re: Redhat-devel-list digest, Vol 1 #1030 - 2 msgs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



is there other available sources on how to use the openpty and forkpty functions?
 
I have tried reading the manpages and surf the net but still cannot find a good source... I am having a hard time understanding this functions...
 
I cannot seem to figure on how to attch the slave pseudo to the ssh...
 
tnx...
redhat-devel-list-request@xxxxxxxxxx wrote:
Send Redhat-devel-list mailing list submissions to
redhat-devel-list@xxxxxxxxxx

To subscribe or unsubscribe via the World Wide Web, visit
https://www.redhat.com/mailman/listinfo/redhat-devel-list
or, via email, send a message with subject or body 'help' to
redhat-devel-list-request@xxxxxxxxxx

You can reach the person managing the list at
redhat-devel-list-admin@xxxxxxxxxx

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Redhat-devel-list digest..."

Today's Topics:

1. remote login (mara ailiez sy)
2. Re: remote login (Kevin Smathers)


> ATTACHMENT part 3.1 message/rfc822
Date: Sun, 1 Feb 2004 23:11:53 -0800 (PST)
From: mara ailiez sy
Subject: remote login
To: redhat-devel-list@xxxxxxxxxx

Hello...

I am currently developing my undergrad thesis and is
developing a remote login with the username and
password supplied. I have created the code below.
However, I keep getting an error about "Pseudo
termnial cannot be allocated because the stdin is not
a terminal". Then a permission denied ... I was
wondering if the use of pipe as the communication
between the processes can be done?



#include
#include
#include
#include
#include

#define BUFFERSIZE 256



int main() {

int n;
char buffer[BUFFERSIZE];

int fds_ci[2]; // file descriptors - child input


int fds_co[2]; // file descriptors - child output


// create the I/O pipes
if (0 != pipe(fds_ci) || 0 != pipe(fds_co)) return
1;

// create the child process
if (fork() == 0)
{

// in the child process
dup2(fds_ci[1], 0);

dup2(fds_co[0], 1);


close(fds_ci[0]);
close(fds_ci[1]);
close(fds_co[0]);
close(fds_co[1]);


execl("/usr/bin/ssh", "ssh", "root@localhost",
NULL);
return 2;

}

// in parent process
close(fds_ci[1]);
close(fds_co[0]);

write(fd_ci[1], "password", BUFFERSIZE);

// read child's output and redirect it to standard
output
while (0 < (n = read(fds_co[0], buffer,
BUFFERSIZE))) {
// write to the parent's stdout
write(stdout, buffer, n);
}


// close the remaining pipes
close(fds_ci[0]);
close(fds_co[1]);

return 0;
}


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/




> ATTACHMENT part 3.2 message/rfc822
Date: Sun, 01 Feb 2004 23:22:04 -0800
From: Kevin Smathers
To: redhat-devel-list@xxxxxxxxxx
Subject: Re: remote login

! You'll have to attach the slave side of a pseudo terminal to stdio
descriptors of the 'ssh' command.

man openpty

Cheers,
-kls

mara ailiez sy wrote:

>Hello...
>
>I am currently developing my undergrad thesis and is
>developing a remote login with the username and
>password supplied. I have created the code below.
>However, I keep getting an error about "Pseudo
>termnial cannot be allocated because the stdin is not
>a terminal". Then a permission denied ... I was
>wondering if the use of pipe as the communication
>between the processes can be done?
>
>
>
>#include
>#include
>#include
>#include
>#include
>
>#define BUFFERSIZE 256
>
>
>
>int main() {
>
> int n;
> char buffer[BUFFERSIZE];
>
> int fds_ci[2]; // file descriptors -! child input
>
>
> int fds_co[2]; // file descriptors - child output
>
>
> // create the I/O pipes
> if (0 != pipe(fds_ci) || 0 != pipe(fds_co)) return
>1;
>
> // create the child process
> if (fork() == 0)
> {
>
> // in the child process
> dup2(fds_ci[1], 0);
>
> dup2(fds_co[0], 1);
>
>
> close(fds_ci[0]);
> close(fds_ci[1]);
> close(fds_co[0]);
> close(fds_co[1]);
>
>
> execl("/usr/bin/ssh", "ssh", "root@localhost",
>NULL);
> return 2;
>
> }
>
> // in parent process
> close(fds_ci[1]);
> close(fds_co[0]);
>
> write(fd_ci[1], "password", BUFFERSIZE);
>
> // read child's output and redirect it to standard
>output
> while (0 < (n = read(fds_co[0], buffer,
>BUFFERSIZE))) {
> // write to the parent's stdout
> write(stdout, ! buffer, n);
> }
>
>
> // close the remaining pipes
> close(fds_ci[0]);
> close(fds_co[1]);
>
> return 0;
>}
>
>
>__________________________________
>Do you Yahoo!?
>Yahoo! SiteBuilder - Free web site building tool. Try it!
>http://webhosting.yahoo.com/ps/sb/
>
>
>_______________________________________________
>Redhat-devel-list mailing list
>Redhat-devel-list@xxxxxxxxxx
>https://www.redhat.com/mailman/listinfo/redhat-devel-list
>
>


--
Look ma, no threads[1].
[1] BitTorrent in C is http://www.sf.net/projects/libbt

// .--=,
.....::://::::::::::::::::::::::::::::.. (o O & kevin@xxxxxxx
:::::::://:::://://://:/:://::||_// / V K
:::::://:::://:/:|//'/' // _,|' r , 'qk
:'''/____ // / // |_// // || .'~. .~`,
kls \_/-=\_/






_______________________________________________
Redhat-devel-list mailing list
Redhat-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/redhat-devel-list


Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!

[Index of Archives]     [Kernel Newbies]     [Red Hat General]     [Fedora]     [Red Hat Install]     [Linux Kernel Development]     [Yosemite News]

  Powered by Linux