[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

sending stdin to a daemon telnet process??

Posted on 2001-08-04
5
Medium Priority
?
919 Views
Last Modified: 2013-12-03
I need to port an application from Unix to NT/2000.  On Unix, I have spawned a telnet application as a daemon process, and my applications can send information to it using  telnets process ID.  I want to be able to do the same within Windows.  There are two parts to this question:
     1) Within my application, how do I create a new process (running a console telnet application)  which will persist even after the spawning application dies?  I have a console version of telnet;  however, I do not actually need to see the console.  However, I need the telnet process to stay alive even after the spawning application dies so I can have other applications connect to it in the future.
     2) How can I send messages to that telnet process, and have that process receive them as if they were comming from stdin?  I believe I can redirect stdin if that would help.

please include sample code!

Thanks!

0
Comment
Question by:ivang061698
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 15

Expert Comment

by:NickRepin
ID: 6352748
1) Use just CreateProcess()

2)

INFO: Redirection Issues on Windows 95 MS-DOS Applications
http://support.microsoft.com/support/kb/articles/Q150/9/56.ASP

Q190351 - HOWTO: Spawn Console Processes with Redirected Standard Handles
http://support.microsoft.com/support/kb/articles/Q190/3/51.ASP
0
 

Author Comment

by:ivang061698
ID: 6352759
Thanks NickRepin, that's a good start.
There are two differences between what I need and what the HOWTO demonstrates.  Perhaps I can clarify what I need.  I have one application which will create the Telnet process.  This telnet process hopefully will stay alive even after the original application dies.  Then, when other applications are executed, and they want to send commands to this pre-existing Telnet session, they can connect to it and send the commands via redirected standard input.  In unix, you can do this by sending info via a process ID.

0
 
LVL 15

Accepted Solution

by:
NickRepin earned 1200 total points
ID: 6354703
I see now. So Telnet is an existing application, which uses stdin, and you cannot change it?

I think the following should work:

You create a program which CreateNamedPipe() first, and then CreateProcess("Telnet",...DETACHED_PROCESS...). The named pipe handle must be passed to Telnet as described in the articles above. DETACHED_PROCESS might be used to hide Telnet from the user. The program can now exit. The named pipe must survive, because its handle is duplicated.

Now you can use CreateFile() and WriteFile() to connect and write to the named pipe from another process.

Note that you might need to redirect the stdout of Telnet as well.
0
 
LVL 15

Expert Comment

by:NickRepin
ID: 6401950
did it help?
0
 

Author Comment

by:ivang061698
ID: 6402157
Yes.  Thanks for the tips!
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question