473,327 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Monitor dos file and/or window

I have a program which runs in a dos window. That program generates output and
writes it to the dos window as well as piping it to a text file.

I would like to be able to monitor the window or text file as the program runs
with a dotnet application so that I can create my own log file in SQL server and
perform certain actions depending upon the output in the window/text file.

Does anyone have any suggestions?

Nov 20 '05 #1
4 1264
Hello Mike,

Thanks for your post. As I understand, you want to know how to read the
output of a console window or a text file. Please correct me if there is
any misunderstanding. Now, I'd like to share the following information with
you:

1. I recommend you use FileSystemWatcher class in .NET to monitor the
changes in a specific file, and then read it with StreamReader. Please
refer to the following MSDN articles:

FileSystemWatcher
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemiofilesystemwatcherclasstopic.asp

Reading Text from a File
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconReadingTextFromFile.asp

2. You may be able to read from the Dos Window via Console Functions say,
ReadConsoleOutput. However, they are unmanaged APIs, you should use
Platform Invoke to call these functions.

ReadConsoleOutput
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/readconsoleoutput.asp

Consuming Unmanaged DLL Functions
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconconsumingunmanageddllfunctions.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #2
* Mike <do************@boo.ya> scripsit:
I have a program which runs in a dos window. That program generates output and
writes it to the dos window as well as piping it to a text file.

I would like to be able to monitor the window or text file as the program runs
with a dotnet application so that I can create my own log file in SQL server and
perform certain actions depending upon the output in the window/text file.


<http://www.mvps.org/dotnet/dotnet/samples/miscsamples/downloads/RedirectConsole.zip>

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
The ReadConsoleOutput might be the way to go. Do you know if there is a way to
send text to the console? My program will want to send commands to the console
to perform an action based upon console input.

Thanks!
In article <X$*************@cpmsftngxa07.phx.gbl>, Tian Min Huang says...

Hello Mike,

Thanks for your post. As I understand, you want to know how to read the
output of a console window or a text file. Please correct me if there is
any misunderstanding. Now, I'd like to share the following information with
you:

1. I recommend you use FileSystemWatcher class in .NET to monitor the
changes in a specific file, and then read it with StreamReader. Please
refer to the following MSDN articles:

FileSystemWatcher
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemiofilesystemwatcherclasstopic.asp

Reading Text from a File
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconReadingTextFromFile.asp

2. You may be able to read from the Dos Window via Console Functions say,
ReadConsoleOutput. However, they are unmanaged APIs, you should use
Platform Invoke to call these functions.

ReadConsoleOutput
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/readconsoleoutput.asp

Consuming Unmanaged DLL Functions
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconconsumingunmanageddllfunctions.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 20 '05 #4
Hello Mike,

Thanks for your reply.

1. You can use WriteConsoleInput() to writes data directly to the console
input buffer.

WriteConsoleInput
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/writeconsoleinput.asp

For a complete list of Console Functions, please refer to the link below:
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/console_functions.asp

2. In addition, I recommend that you can also consider redirecting
input/output of your console application as mentioned by Herfried in
another reply. Generally speaking, a console application will use a Console
Window as its startdard input/output. You can also execute a console
application by redirecting its input/output to a file or stream instead of
the Console Window.

Process.StandardInput Property
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdiagnosticsprocessclassstandardinputtop ic.asp

Process.StandardOutput Property
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdiagnosticsprocessclassstandardoutputto pic.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: KJM | last post by:
How can I detect if the user has dual monitors and then how do I control which monitor a form is displayed on. Currently my forms always come up on my right monitor. What if I want to have it...
1
by: HockeyTownUSA | last post by:
I am working a project where I am using two monitors and using HTML/Javascript to display the information I want. I have my main stuff on the main monitor, but when each page loads, I want an...
10
by: santiago538 | last post by:
Hi, Is there any way to specify which monitor a Window.open() will launch a new browser window in on systems with more than one display. It would only need to work with Mozilla browsers, and not...
2
by: Renganathan | last post by:
I have an appliction which has two form winodow in C#. i want to see these window in Simultaneously.This application should supports dual monitor. one window is one monitor and another window is in...
17
by: spentun | last post by:
How can I moitor file which is executed by user or program in window. I need to write a code to monitor file. When user clicks the file(.exe) or is called by program, the name of file will be...
4
by: John | last post by:
I'd like to write a programme that runs on a PC with two monitors. The application would be used in a shop, with one monitor for shop assistant and the other for the customer. The two must show...
8
by: Sheldon | last post by:
I just received a 2nd (configured as a dual) monitor but, for Access only, I can't seem to figure out, if it's possible, to view, say, Table1 on one monitor and Table2 on the other monitor. If I...
1
by: nanban4u | last post by:
Hi, Programming Language - HTML, JavaScript Web server : IIS 6 Browser : IE 6 + I am working in a Dual Monitor screen setup. I have a scenario some times the user move the IE screen from...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.