tags:

views:

1796

answers:

4

Hi!

I'm writing a simple executable in C that needs to open a putty session and send commands to it, then close putty. I can open/close the putty session (i'm not that bad) but i'm not too sure on how to send putty the commands.

Any ideas??

A: 

So if you are opening it with a pipe (e.g. with popen), can't you just write the commands to the write-end of the pipe?

-- MarkusQ

MarkusQ
Putty is not a console program; it doesn't read from stdin, so any pipes would be ignored.
Rob Kennedy
A: 

Have you looked at the source for QuickPutty? It's LGPL licensed.

Alnitak
But what IS it? The link provides no information about what it does. Just a half-dozen download links.
Rob Kennedy
it's a quick-start front-end to PuTTY, which provides a desktop window with links to each defined PuTTY profile. If the OP actually wants to send I/O to an SSH shell started via PuTTY it's probably not that useful.
Alnitak
+1  A: 

Use the DLL, Luke. http://www.winputty.com/

vartec
+2  A: 

From the PuTTY FAQ:

How can I use PuTTY to make an SSH connection from within another program?

Probably your best bet is to use Plink, the command-line connection tool. If you can start Plink as a second Windows process, and arrange for your primary process to be able to send data to the Plink process, and receive data from it, through pipes, then you should be able to make SSH connections from your program.

This is what CVS for Windows does, for example.

Plink can use PuTTY's saved sessions in addition to opening sites directly.

PLink's options are documented in Chapter 7 of the PuTTY manual.

R. Bemrose