468,785 Members | 1,705 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,785 developers. It's quick & easy.

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 1297
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

Post your reply

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

Similar topics

4 posts views Thread by Mark Wilson CPU | last post: by
3 posts views Thread by Steve | last post: by
8 posts views Thread by AMeador | last post: by
2 posts views Thread by Steve | last post: by
4 posts views Thread by garyusenet | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.