FAQFAQ   SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log in/Register/PasswordLog in/Register/Password

How do I telnet programmatically?

 
   Mac (Home) -> Programmer Help RSS
Related Topics:
How to type in ASCII? - Stupid question #2 of the week. I'm trying to avoid writing a printer driver for a barcode label printer. It responds to commands, and I want to embed a command in a page that tells the printer to cut the paper. It's o STX, of course..

applications and windows - Hello. I'm primarily a system unix one. Currently I have to implement the following logic: On Mac OS X enumerate all running only those that are windows. Find which of them is where is defined as..

[ANN] Vice - Graphical Program Priority Adjustment Tool fo.. - Vice is an that allows the user to adjust the priority of programs running on Mac OS X. Normal users can lower the priority of their own programs, while can adjust the priority of any..

NSCursorAttributeName and NSTextView - Well, I've been playing around a little bit with getting URLs in my to actually become clickable links. So far, so good. I set the for my strings that get inserted into the text view: for the link..

adding graphics to my console app - I need to add to my UI, C code). This just means being able to open a window and display data in graphical format. I have a couple of options: 1. Dredge up ancient QuickDraw code I..
Next:  Programmer Help: Any help viewer differences between 10.4 and 10.5?  
Author Message
Jim

External


Since: Apr 10, 2007
Posts: 26



(Msg. 1) Posted: Fri Aug 29, 2008 4:00 pm
Post subject: How do I telnet programmatically?
Archived from groups: comp>sys>mac>programmer>help (more info?)

Actually that might be the wrong question. Here's what I want to do:

I want to write a small app that periodically polls my ADSL router and
retrieves the current line speed. In order to do that manually I can telnet
to it, then go through a 'username' and 'password' prompt, then issue the
command 'adsl info'. After than the telnet session can be killed.

What would be the best way to do this in Cocoa?

The router (a USR model) _does_ have a web interface, but it would still
requite authentication and I'm not sure the info page is a discreet HTML
page, but rather some sort of javascripty stuff.

Many thanks for any pointers, no pun intended.

Jim
--
http://www.ursaMinorBeta.co.uk http://twitter.com/GreyAreaUK

Things our resident MCSE didn't know how to do today:
Forward a port on a router. Even when being talked through it
Back to top
Login to vote
Allen Brunson

External


Since: Aug 29, 2008
Posts: 1



(Msg. 2) Posted: Fri Aug 29, 2008 4:00 pm
Post subject: Re: How do I telnet programmatically? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Jim wrote:
> I want to write a small app that periodically polls my ADSL router and
> retrieves the current line speed. In order to do that manually I can telnet
> to it, then go through a 'username' and 'password' prompt, then issue the
> command 'adsl info'. After than the telnet session can be killed.

telnet is an extremely simple protocol. you create a tcp/ip stream connection
to a server, send lines to it terminated with CR/LF pairs, and it sends lines
back in exactly the same fashion.

you can do this easily with plain old bsd sockets. here's the first tutorial
i googled up:

http://www.linuxquestions.org/linux/answers/Programming/BSD_Sockets_programm
ing_in_C_with_examples


> What would be the best way to do this in Cocoa?

there may be a cocoa wrapper around bsd sockets, i don't know. personally i
always use the raw socket interface, which is a perfectly reasonable approach
in a cocoa program, so i've never investigated such a thing.
Back to top
Login to vote
Sherm Pendley

External


Since: Dec 12, 2006
Posts: 27



(Msg. 3) Posted: Fri Aug 29, 2008 4:00 pm
Post subject: Re: How do I telnet programmatically? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Allen Brunson <noemail.RemoveThis@spam.com.invalid> writes:

> Jim wrote:
>
>> What would be the best way to do this in Cocoa?
>
> there may be a cocoa wrapper around bsd sockets, i don't know.

There's not much to wrap. All you need to do is pass the file
descriptor you get back from socket() to NSFileHandle's
-initWithFileDescriptor: initializer.

sherm--

--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
Back to top
Login to vote
Simon Slavin

External


Since: Aug 24, 2005
Posts: 113



(Msg. 4) Posted: Sun Aug 31, 2008 8:31 pm
Post subject: Re: How do I telnet programmatically? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 29/08/2008, Sherm Pendley wrote in message <m11w07wx4e.fsf.RemoveThis@dot-app.org>:

> Allen Brunson <noemail.RemoveThis@spam.com.invalid> writes:
>
> > Jim wrote:
> >
> >> What would be the best way to do this in Cocoa?
> >

>
> There's not much to wrap.

Is there really not much to wrap ? Don't you have to have to handle
buffering ? Especially if there's significant lag when accessing the
server ?

Simon.
--
http://www.hearsay.demon.co.uk
Back to top
Login to vote
Daniel Flinkmann

External


Since: Sep 23, 2008
Posts: 1



(Msg. 5) Posted: Tue Sep 23, 2008 5:02 pm
Post subject: Re: How do I telnet programmatically? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Fri, 29 Aug 2008 16:00:50 +0100, Jim wrote:

> I want to write a small app that periodically polls my ADSL router and
> retrieves the current line speed. In order to do that manually I can
> telnet to it, then go through a 'username' and 'password' prompt, then
> issue the command 'adsl info'. After than the telnet session can be
> killed.

I would use "expect". Thats one of the typical unix power tools and
should be available for the mac too.

Just google for "except telnet examples" and you should have plenty
of examples which will do exactly what you want.

Cheers,

Daniel
Back to top
Login to vote
Jim

External


Since: Apr 12, 2007
Posts: 7



(Msg. 6) Posted: Tue Sep 23, 2008 7:45 pm
Post subject: Re: How do I telnet programmatically? [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Daniel Flinkmann <spam_spam_spam RemoveThis @flinkmann.de> wrote:

> On Fri, 29 Aug 2008 16:00:50 +0100, Jim wrote:
>
> > I want to write a small app that periodically polls my ADSL router and
> > retrieves the current line speed. In order to do that manually I can
> > telnet to it, then go through a 'username' and 'password' prompt, then
> > issue the command 'adsl info'. After than the telnet session can be
> > killed.
>
> I would use "expect". Thats one of the typical unix power tools and
> should be available for the mac too.
>
> Just google for "except telnet examples" and you should have plenty
> of examples which will do exactly what you want.


Thanks, but I was able to do it with NSInputStream and NSOutputStream.

Mind you, I ended up effectively coding send/expect methods, so it was
perhaps overkill. I'll check out "expect" next time. Thank you.

Jim
--
'Cloverfield' in nine words: "What is it?!" "We're gonna die!" BOOM!
Roll credits.

http://www.ursaminorbeta.co.uk http://twitter.com/greyareauk
Back to top
Login to vote
Display posts from previous:   
       Mac (Home) -> Programmer Help All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum
Categories:
 Windows Forums
 Game Forums
 Linux Forums
  Mac Forums
 PDA Forums
 Mobile Forums
  Top  |  Store  |  RSS Feeds RSS  |  Data Feeds  |  Advertise  |  Submit  |  Bookmark  |  Newsletter  |  Contact