473,385 Members | 1,736 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,385 software developers and data experts.

Get output from DOS application with UI - not a command line application

Hello, all, I see there are some true experts here on the forum, so maybe someone can help me.

I need to get output from DOS application that does some calculations based on the choices that user makes in it. Thre are 4-5 choices to choose, and then the calculated data is either printed or shown on the screen. Printing works just fine, however I have a problem with previewing data. I need to preview data becuase manytimes there isnt a printer to conencti notebook to.

The problem with previewing is that data listing is several pages long, and paging doesnt occur, so 90% of the data is just scrolled out, and only the bottom lines of the listing is visible. How can I capture the whole data?

Stuff like

App.exe > c:\text.txt

doesnt work. Also, I have failed to achieve this with System.Debugging.Process class. I can get output when the application is a command line application, and when application doesnt need user interaction. However, I have some menus in this app, and user needs to interact with them, in order to get the result.

Does anyone knows for sure if this is possible or not?

Thanks,
Goran
Oct 1 '07 #1
6 1528
Plater
7,872 Expert 4TB
You have a DOS application with menus?
Does it use like DOS4GW or some other gdfx library?

The process class can do standard streams for inpute/ouput/error, but that only works for commandline.

You could try using SendKeys(), but that might require a UI window.
Oct 1 '07 #2
No, no, it is a standard DOS menu, 1), 2), 3).... a), b), c), d). Application is written in Pascal 3.0,

I don't know what did you mean by SendKeys, but If you meant to use it for choosing options, then it is not needed. User will use keyboard to select options, and in the end there is option to print or preview, so when user presses V button, the data will be displayed on the screen. This is the moment when I need to start capturing data, after the user presses V (preview). Before that I am not interested what is going on. Data is several pages long, so I can see only the last page, like when you type Dir on a folder that has 100 items, only the last 30 (lets say) are visible.

Goran
Oct 1 '07 #3
Plater
7,872 Expert 4TB
Have you tried overriding the standard in/out/error streams in the Process class?
Oct 2 '07 #4
No, I have only tried with StartInfo and rediresting output, which is used for command libe applications. Can you point me to some direction, what is the idea/goal. and what I need to override.

Thanks,
Goran
Oct 2 '07 #5
Plater
7,872 Expert 4TB
Well here's an example for a program i wrote to wrap the nslookup dos command (Yes I know there is a built in version)

nslookup by itsels waits for the user to enter in some data before responding. Redirect the standardInput to send ascii data to the process.
I read it's reply with both the standardOut and standardError (since some information is sent on standard error)

Expand|Select|Wrap|Line Numbers
  1. private string GetLookup(string IPAddy)
  2. {
  3.     string retval = "";
  4.     //ProcessStartInfo psi = new ProcessStartInfo("nslookup", "");
  5.     psi.UseShellExecute=false; 
  6.     psi.RedirectStandardOutput = true;
  7.     psi.RedirectStandardInput = true;
  8.     psi.RedirectStandardError  = true;
  9. //    psi.CreateNoWindow = true;
  10.     Process p = new Process();
  11.     p.StartInfo=psi;
  12.     p.Start();
  13.     StreamWriter si = p.StandardInput;
  14.     StreamReader se = p.StandardError; 
  15.     StreamReader so = p.StandardOutput;
  16. si.WriteLine(IPAddy);
  17. //    si.WriteLine("blank");
  18.     si.WriteLine("exit");
  19.     retval += so.ReadToEnd();
  20.     retval += se.ReadToEnd();
  21.  
  22.     while (!p.HasExited)
  23.     {
  24.         retval += so.ReadToEnd();
  25.         retval += se.ReadToEnd();
  26.     }
  27.     retval += so.ReadToEnd();
  28.     retval += se.ReadToEnd();
  29.     p.Close();
  30.     p.Dispose();
  31.     return retval;
  32. }
  33.  
Oct 2 '07 #6
You have confused me when you said "overriding". Yes, this is the code (more or less) I have used, but the problem with it is, when first options is chosed (a user types some letter), the process ends. I am not sure why, but I couldnt find a way to get around this.

Seems that I will get around with my problem with combination of two software - one that will redirect output from DOS printer to windows printer, and other that will convert this output to pdf format.

Thanks, Goran
Oct 3 '07 #7

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

Similar topics

4
by: Mark Wilson CPU | last post by:
This must be easy, but I'm missing something... I want to execute a Perl script, and capture ALL its output into a PHP variable. Here are my 2 files: -------------------------------------...
3
by: Steve | last post by:
How can I read the output from a command line utility such as ping, nslookup, etc, from within my app??? I know that it is possible to output the results to a text file using the > function in a...
8
by: AMeador | last post by:
I can see console output in the output window on VS, but how can you see this text when running the app on a different machine or outside of VS? Thanks! --- Andrew
2
by: Steve | last post by:
I have created a console app that simply prints out a message a couple times, then exits, here is the code: <code> for(int i = 0; i < 10; i++) { System.Threading.Thread.Sleep(500);...
1
by: lavu | last post by:
I currently have a C# windows Application . I would like this App to work through an command line interface also. I would like to specify command line params, which should start the app and process...
6
by: tommaso.gastaldi | last post by:
Hi I am creating a pdf by just printing on Acrobat Distiller. This is fine. I need to create a pdf which has a given prespecified name and I do not wish that Distiller prompts me for a name....
4
by: garyusenet | last post by:
Hi. I am trying to learn about array lists, and found an example on MSDN. I tried to compile it but it's not producing any output. I can't see why. Any ideas? Here is what I did. 1....
0
by: ptek | last post by:
Hi, I'm using Vstudio 2005 and I did a Windows Application project where I also want to read arguments from command line and output some text when appropriate (for example, typing the correct...
1
by: leonknathan | last post by:
Hi, I'm new to posting questions on this type of forum so if I'm doing something wrong i'll be grateful for any vats of common sense any of you can send in my direction. I have a VBA question -...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

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.