Re: Bridging console port to a telnet session



On Jan 17, 2007, at 11:00 AM, Kailas Ramasamy wrote:

Hi Mike,

Thanks a lot. This is what I was looking for.

-Kailas

On 1/17/07, Mike Meyer <mwm@xxxxxxxxx> wrote:

In <ecd0bee40701171024p7c5b4944of45b4c407ed3c5f4@xxxxxxxxxxxxxx>, Kailas
Ramasamy <kailasr@xxxxxxxxx> typed:
> Hi Mike,
> I read through fork() and exec() man pages but I couldn't find anything
> related to
> this. Basically, I want to launch a telnet session from a process and
pass
> in
> /dev/console as stdin and stdout.

Well, you don't really need fork(), though fork() follows exec() so
often than some OS's combine them into a single call. And I just
noticed that if you do "man exec", you get the shell's page - you want
exec(3), to get the C calls.

Anyway, the sequence is:

Use open() to get an fd pointing at /dev/console.
Use dup2() to copy that fd to stdin and stdout (and probably stderr).
Use an exec() function to launch telnet.

<mike


> Thanks
> Kailas
>
> On 1/16/07, Mike Meyer <mwm@xxxxxxxxx> wrote:
> >
> > In <ecd0bee40701161732v26112f24o2d8323c2777d2f7@xxxxxxxxxxxxxx>,
Kailas
> > Ramasamy <kailasr@xxxxxxxxx> typed:
> > > Hi Mike,
> > > Yes, that what I am planing but I want to do this dynamically. Do
you
> > know
> > > how to launch a
> > > telnet session from a process?. How do I pass stdin and stdout to
the
> > telnet
> > > from a process?.
> >
> > See the fork() and exec() man pages.
> >
> > <mike
> >
> >
> > > On 1/16/07, Mike Meyer <mwm@xxxxxxxxx> wrote:
> > > >
> > > > In <ecd0bee40701161503k385819ddgba5562e137630617@xxxxxxxxxxxxxx>,
> > Kailas
> > > > Ramasamy <kailasr@xxxxxxxxx> typed:
> > > > > Hi,
> > > > > Within a FreeBSD system, I want to telnet to another system and
> > bridge
> > > > that
> > > > > session to the
> > > > > console port so that when an user connects to the system via
console
> > > > port,
> > > > > it is automatically
> > > > > redirected to other system for I have already established a
telnet
> > > > session.
> > > >
> > > > What's wrong with simply leaving a telnet session running on the
> > > > console, maybe with some support to relaunch it should it ever
exit?
> > > >
> > > > <mike
> > > > --
> > > > Mike Meyer <mwm@xxxxxxxxx>
> > > > http://www.mired.org/consulting.html
> > > > Independent Network/Unix/Perforce consultant, email for more
> > information.
> > > >
> > > _______________________________________________
> > > freebsd-hackers@xxxxxxxxxxx mailing list
> > > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
> > > To unsubscribe, send any mail to "
> > freebsd-hackers-unsubscribe@xxxxxxxxxxx"
> > >
> >
> > --
> > Mike Meyer <mwm@xxxxxxxxx>
> > http://www.mired.org/consulting.html
> > Independent Network/Unix/Perforce consultant, email for more
information.
> >
> Hi Mike,<br>I read through fork() and exec() man pages but I
couldn&#39;t find anything related to<br>this. Basically, I want to launch a
telnet session from a process and pass in <br>/dev/console as stdin and
stdout. <br>
> <br>Thanks<br>Kailas<br><br><div><span class="gmail_quote">On 1/16/07,
<b class="gmail_sendername">Mike Meyer</b> &lt;<a href="mailto:
mwm@xxxxxxxxx">mwm@xxxxxxxxx</a>&gt; wrote:</span><blockquote
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204);
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> In &lt;<a href="mailto:
ecd0bee40701161732v26112f24o2d8323c2777d2f7@xxxxxxxxxxxxxx">
ecd0bee40701161732v26112f24o2d8323c2777d2f7@xxxxxxxxxxxxxx</ a>&gt;, Kailas
Ramasamy &lt;<a href="mailto:kailasr@xxxxxxxxx";>kailasr@xxxxxxxxx
> </a>&gt; typed:<br>&gt; Hi Mike,<br>&gt; Yes, that what I am planing but
I want to do this dynamically. Do you know<br>&gt; how to launch a<br>&gt;
telnet session from a process?. How do I pass stdin and stdout to the telnet
> <br>&gt; from a process?.<br><br>See the fork() and exec() man
pages.<br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;mik e<br><br><br>&gt;
On 1/16/07, Mike Meyer &lt;<a href="mailto:mwm@xxxxxxxxx";>mwm@xxxxxxxxx</a>&gt;
wrote:<br>&gt; &gt;<br>&gt; &gt; In &lt;
> <a href="mailto:
ecd0bee40701161503k385819ddgba5562e137630617@xxxxxxxxxxxxxx">
ecd0bee40701161503k385819ddgba5562e137630617@xxxxxxxxxxxxxx</a>&gt;,
Kailas<br>&gt; &gt; Ramasamy &lt;<a href="mailto:kailasr@xxxxxxxxx";>
kailasr@xxxxxxxxx
> </a>&gt; typed:<br>&gt; &gt; &gt; Hi,<br>&gt; &gt; &gt; Within a FreeBSD
system, I want to telnet to another system and bridge<br>&gt; &gt;
that<br>&gt; &gt; &gt; session to the<br>&gt; &gt; &gt; console port so that
when an user connects to the system via console
> <br>&gt; &gt; port,<br>&gt; &gt; &gt; it is automatically<br>&gt; &gt;
&gt; redirected to other system for I have already established a
telnet<br>&gt; &gt; session.<br>&gt; &gt;<br>&gt; &gt; What&#39;s wrong with
simply leaving a telnet session running on the
> <br>&gt; &gt; console, maybe with some support to relaunch it should it
ever exit?<br>&gt; &gt;<br>&gt;
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;mike<br>&gt; &gt;
--<br>&gt; &gt; Mike Meyer &lt;<a href="mailto:mwm@xxxxxxxxx";>
mwm@xxxxxxxxx</a>&gt;
> <br>&gt; &gt; <a href="http://www.mired.org/consulting.html";>
http://www.mired.org/consulting.html</a><br>&gt; &gt; Independent
Network/Unix/Perforce consultant, email for more information.<br>&gt;
&gt;<br>&gt;

Kailas cross posted this to the questions@ list too. I gave a possible answer there.
-Garrett
_______________________________________________
freebsd-hackers@xxxxxxxxxxx mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@xxxxxxxxxxx"



Relevant Pages

  • Re: Bridging console port to a telnet session
    ... On 1/17/07, Mike Meyer wrote: ... Well, you don't really need fork(), though forkfollows exec() so ... >>> telnet session from a process?. ...
    (freebsd-hackers)
  • Re: Bridging console port to a telnet session
    ... On Jan 17, 2007, at 11:00 AM, Kailas Ramasamy wrote: ... On 1/17/07, Mike Meyer wrote: ... Well, you don't really need fork(), though forkfollows execso ... >>> telnet session from a process?. ...
    (freebsd-questions)
  • Re: How to Transparently Connect Two Sockets?
    ... > The easiest way is just to fork off two child processes, ... descriptors to map one socket to another? ... Mike ...
    (comp.unix.programmer)
  • Re: Where to download Mark Fletchers ResourcePackage?
    ... Sorry Mike. ... Thanks for the note Peter. ... >> Gusess I took the wrong fork in the road when I decided to get out of ...
    (comp.lang.python)
  • Re: is this true about US forking habits?
    ... Mike.. ... the food still with the fork in the left hand while cutting it with the ... It only seems awkward to Americans because we are not accustomed to it - it's a simple enough skill to develop, if one really wants to do so. ...
    (rec.travel.europe)