Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

remote shell, help needed

0 views
Skip to first unread message

Giff

unread,
Nov 6, 2005, 3:49:54 PM11/6/05
to
Hi all

I'm trying to develop a remote shell using unix (debian sarge) and C

I'm stuck at the point when I have to return the output of a command
from the server to the client, I'm trying to redirect the stdout and
stderr to a temporary txt file (freopen + popen), then read from it and
send the results to the socket but I can't make it work...
I would post my code but it's so messy than I'd rather ask if any of you
have a code sample of this process (executing a command on the server
and send back the results to the client)

thanks a lot

G

Basile Starynkevitch [news]

unread,
Nov 6, 2005, 7:51:18 PM11/6/05
to
On 2005-11-06, Giff <giffnews...@gmail.com> wrote:

> I'm trying to develop a remote shell using unix (debian sarge) and C

Then I strongly suggest diving into the sources of rsh (ie the
rsh-client and rsh-server debian packages)


--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile(at)starynkevitch(dot)net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

Giff

unread,
Nov 6, 2005, 8:25:28 PM11/6/05
to
Basile Starynkevitch [news] ha scritto:

> On 2005-11-06, Giff <giffnews...@gmail.com> wrote:
>
>
>>I'm trying to develop a remote shell using unix (debian sarge) and C
>
>
> Then I strongly suggest diving into the sources of rsh (ie the
> rsh-client and rsh-server debian packages)

thanks, I'll try to dive then ;)

Kasper Dupont

unread,
Nov 7, 2005, 4:58:16 AM11/7/05
to

There already exists implementations of what you are trying to do
(but if this is just intended as an exercise to get to know the
system, doing it again may still be relevant). Examples doing
what you are trying to do include rsh, rlogin, telnet, and finally
ssh which is a more secure replacement for all of them.

The part about redirecting i/o is typically done through a pseudo
tty, which you can read a bit about here:
http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#ptmx

Only few programs need stdio to be attached to a tty. If you don't
need a tty, it may be simpler to use pipes or just attach the program
directly to the socket.

freopen and popen are completely irrelevant for what you are trying
to do. Instead you should look into dup2 and close. You may also find
a need for fork and exec*.

--
Kasper Dupont
Note to self: Don't try to allocate
256000 pages with GFP_KERNEL on x86.

Giff

unread,
Nov 13, 2005, 7:39:56 AM11/13/05
to
Kasper Dupont ha scritto:

> freopen and popen are completely irrelevant for what you are trying
> to do. Instead you should look into dup2 and close. You may also find
> a need for fork and exec*.

I tried with fork and exec but I didn't manage to redirect the output to
the socket or the temp file cause when I call the exec it starts its own
stdout and stderr


--
remove numbers from email address if willing to send private message

Kasper Dupont

unread,
Nov 13, 2005, 1:17:32 PM11/13/05
to
Giff wrote:
>
> I tried with fork and exec but I didn't manage to redirect the output to
> the socket or the temp file cause when I call the exec it starts its own
> stdout and stderr

Most likely you are doing something wrong
when trying to redirect the output.

0 new messages