By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,136 Members | 1,021 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,136 IT Pros & Developers. It's quick & easy.

Plss advise on writing VC++ code for interactive execution of an executable (Plink)

P: 4

I'm trying to write VC++ code for using Plink (command-line tool of PuTTY) interactively from within my program which is a console type windows application.

The basic purpose is to run commands on a Linux server remotely from my windows application through encrypted ssh provided by the Plink tool. And the result returned from the server needs to be captured in a log file for further processing. I plan to segregate this code into a separate DLL so that it can be called from the primary windows console app, and will run as a backend to it.

My main concerns are:
* Which function call should I be using to run the command-line Plink tool, is it System() or ShellExecute() or do you suggest a diff. alternative?
* After I send a command, how do I capture the STDOUT and STDERROR (without terminating this instance, i.e. keeping it interactive) so that I can check if the server is waiting for additional input or if the command has been executed?

As I'm previously from a linux background, I would really be thankful if you can point me on how to go about implementing this in VC++ (

Thanking you in advance!

Mar 12 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 8,916
Use CreateProcess

In the STARTUPINFO structure you can supply handles to OS objects to use for stdin, stdout and stderr. By creating and using pipes you can then direct the output back to your own process.

You will need to set the InheritHandles parameter to TRUE.
Mar 12 '07 #2

P: 4
Thanks Banfa, I'm going ahead with your idea.

Hope you will help me out if I run into some trouble!

Mar 14 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.