Re: not so IDL related... Command line auto-feed [message #61121] |
Tue, 08 July 2008 10:41 |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
> Assuming the program uses standard input, you should be able to create a
> file, called input.txt (pick a name, any name) that looks
> like this.
>
> infile
> outfile
> x
>
> then run the program like this
>
> program < input.txt
>
> If you then wrap a loop around the whole thing, it should be a piece of
> cake.
>
>
Ahh, another great way! Thanks a lot!
As a matter of fact, it works even better than copying the list of
inputs (one of them disappear during the execution of the prog)!
Jean
|
|
|
Re: not so IDL related... Command line auto-feed [message #61123 is a reply to message #61121] |
Tue, 08 July 2008 09:51  |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
Bob,
wow, thanks a lot!!!!!
Easy and effective, great!!!!
I will write that technique down!!!
Jean
> I did something similar, had an executable that has several prompts.
> I wrote an IDL program to write all of the responses to a text file,
> then copied it to the clipboard, ran the exe in a cmd window,
> and used the window menu to paste that huge text file into the
> dos window. (the window menu is at the very top left part
> of the dos window - it says Restore, Move, Resize, etc.)
>
> It executed the program, and correctly inputted all
> required info. I was able to run a thousand runs in about an hour
> (rather than several weeks of typing stuff in by hand).
>
>
> Cheers,
> bob
>
>
|
|
|
Re: not so IDL related... Command line auto-feed [message #61124 is a reply to message #61123] |
Tue, 08 July 2008 09:53  |
Jean H.
Messages: 472 Registered: July 2006
|
Senior Member |
|
|
Rick,
Thanks for the info! ... I will go with Bob's suggestion as it is very
easy to implement.. and I will keep yours for the day that this kind
of process has to be down in the "middle" of another program! Thanks a lot!
Jean
Rick Towler wrote:
> I would first try one of the many mouse/keyboard "macro" utilities.
> Something like www.autohotkey.com. I haven't used this one in
> particular (and I can't remember what program I used to do something
> like this in the past) but most of these allow you to create text based
> scripts that drive the application. Once you work out the details you
> can write a program in IDL that creates the scripts given your inputs.
>
> Another option would be to do it in VB. I've done this successfully as
> well. Something like:
>
> Imports System.IO
> Imports System.Diagnostics
> Imports Microsoft.Win32
>
> Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
> Private psInfo As System.Diagnostics.ProcessStartInfo
> Private process As process
>
> exeFile = "notepad.exe"
> psInfo = New System.Diagnostics.ProcessStartInfo(exeFile)
> process = System.Diagnostics.Process.Start(psInfo)
>
> process.WaitForInputIdle(3000)
> System.Windows.Forms.SendKeys.SendWait("This is a test...")
> System.Windows.Forms.SendKeys.SendWait("%f")
> Sleep(500)
> System.Windows.Forms.SendKeys.SendWait("s")
> Sleep(500)
> System.Windows.Forms.SendKeys.SendWait("test.txt")
> Sleep(500)
> System.Windows.Forms.SendKeys.SendWait("%s")
> sleep(500)
>
>
> You would of course want the application to read the inputs from a text
> file, start the process, send the inputs, monitor the process and then
> loop when the process exits. I don't know if there is an "isRunning"
> property for the System.Diagnostics.Process class. My guess is that
> there is something you could use.
>
> Good luck!
>
> -Rick
>
>
>
>
> Jean H wrote:
>> Hi all,
>>
>> sorry for the misuse of this forum... though one of the smart here may
>> be of great help!
>>
>> Ok, I have to process about 200 files though a program called dem2xyzn
>> (for USGS DEM files). This program runs only under windows (and dos),
>> and have basically no support. You start the program, then it ask for
>> the name of the input file, then for the name of the output file, then
>> if you are sure you want to continue etc.
>>
>> I want to automate all of this...
>> There seems to be no way of specifying the parameters values (input,
>> output) when calling the program.
>>
>> Is there a way to have a text being written in the current dos window?
>> something that would look like, in pseudo-code:
>>
>> -call the program
>> -write input1
>> -write input2
>> -write any letter to tell the prog to continue
>> =start again with another set of input?
>>
>> I have tried to do a batch file, but the "write input1" get executed
>> after the program has resumed...
>>
>> Any help of hints would be greatly appreciated!!!
>> Jean
|
|
|
Re: not so IDL related... Command line auto-feed [message #61127 is a reply to message #61123] |
Tue, 08 July 2008 09:49  |
Bruce Bowler
Messages: 128 Registered: September 1998
|
Senior Member |
|
|
On Mon, 07 Jul 2008 17:00:07 -0600, Jean H wrote:
> Hi all,
>
> sorry for the misuse of this forum... though one of the smart here may
> be of great help!
>
> Ok, I have to process about 200 files though a program called dem2xyzn
> (for USGS DEM files). This program runs only under windows (and dos),
> and have basically no support. You start the program, then it ask for
> the name of the input file, then for the name of the output file, then
> if you are sure you want to continue etc.
>
> I want to automate all of this...
> There seems to be no way of specifying the parameters values (input,
> output) when calling the program.
>
> Is there a way to have a text being written in the current dos window?
> something that would look like, in pseudo-code:
>
> -call the program
> -write input1
> -write input2
> -write any letter to tell the prog to continue =start again with another
> set of input?
>
> I have tried to do a batch file, but the "write input1" get executed
> after the program has resumed...
>
> Any help of hints would be greatly appreciated!!! Jean
Assuming the program uses standard input, you should be able to create a
file, called input.txt (pick a name, any name) that looks
like this.
infile
outfile
x
then run the program like this
program < input.txt
If you then wrap a loop around the whole thing, it should be a piece of
cake.
--
+-------------------+--------------------------------------- ------------+
Bruce Bowler | Sin boldly! - Martin Luther
1.207.633.9600 |
bbowler@bigelow.org |
+-------------------+--------------------------------------- ------------+
|
|
|
Re: not so IDL related... Command line auto-feed [message #61135 is a reply to message #61127] |
Mon, 07 July 2008 17:24  |
Rick Towler
Messages: 821 Registered: August 1998
|
Senior Member |
|
|
I would first try one of the many mouse/keyboard "macro" utilities.
Something like www.autohotkey.com. I haven't used this one in
particular (and I can't remember what program I used to do something
like this in the past) but most of these allow you to create text based
scripts that drive the application. Once you work out the details you
can write a program in IDL that creates the scripts given your inputs.
Another option would be to do it in VB. I've done this successfully as
well. Something like:
Imports System.IO
Imports System.Diagnostics
Imports Microsoft.Win32
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private psInfo As System.Diagnostics.ProcessStartInfo
Private process As process
exeFile = "notepad.exe"
psInfo = New System.Diagnostics.ProcessStartInfo(exeFile)
process = System.Diagnostics.Process.Start(psInfo)
process.WaitForInputIdle(3000)
System.Windows.Forms.SendKeys.SendWait("This is a test...")
System.Windows.Forms.SendKeys.SendWait("%f")
Sleep(500)
System.Windows.Forms.SendKeys.SendWait("s")
Sleep(500)
System.Windows.Forms.SendKeys.SendWait("test.txt")
Sleep(500)
System.Windows.Forms.SendKeys.SendWait("%s")
sleep(500)
You would of course want the application to read the inputs from a text
file, start the process, send the inputs, monitor the process and then
loop when the process exits. I don't know if there is an "isRunning"
property for the System.Diagnostics.Process class. My guess is that
there is something you could use.
Good luck!
-Rick
Jean H wrote:
> Hi all,
>
> sorry for the misuse of this forum... though one of the smart here may
> be of great help!
>
> Ok, I have to process about 200 files though a program called dem2xyzn
> (for USGS DEM files). This program runs only under windows (and dos),
> and have basically no support. You start the program, then it ask for
> the name of the input file, then for the name of the output file, then
> if you are sure you want to continue etc.
>
> I want to automate all of this...
> There seems to be no way of specifying the parameters values (input,
> output) when calling the program.
>
> Is there a way to have a text being written in the current dos window?
> something that would look like, in pseudo-code:
>
> -call the program
> -write input1
> -write input2
> -write any letter to tell the prog to continue
> =start again with another set of input?
>
> I have tried to do a batch file, but the "write input1" get executed
> after the program has resumed...
>
> Any help of hints would be greatly appreciated!!!
> Jean
|
|
|
Re: not so IDL related... Command line auto-feed [message #61136 is a reply to message #61135] |
Mon, 07 July 2008 16:35  |
R.G. Stockwell
Messages: 363 Registered: July 1999
|
Senior Member |
|
|
"Jean H" <jghasban@DELTHIS.ucalgary.ANDTHIS.ca> wrote in message
news:g4u75l$s37$1@news.ucalgary.ca...
> Hi all,
>
> sorry for the misuse of this forum... though one of the smart here may be
> of great help!
>
> Ok, I have to process about 200 files though a program called dem2xyzn
> (for USGS DEM files). This program runs only under windows (and dos), and
> have basically no support. You start the program, then it ask for the name
> of the input file, then for the name of the output file, then if you are
> sure you want to continue etc.
>
> I want to automate all of this...
> There seems to be no way of specifying the parameters values (input,
> output) when calling the program.
>
> Is there a way to have a text being written in the current dos window?
> something that would look like, in pseudo-code:
>
> -call the program
> -write input1
> -write input2
> -write any letter to tell the prog to continue
> =start again with another set of input?
>
> I have tried to do a batch file, but the "write input1" get executed after
> the program has resumed...
>
> Any help of hints would be greatly appreciated!!!
> Jean
I did something similar, had an executable that has several prompts.
I wrote an IDL program to write all of the responses to a text file,
then copied it to the clipboard, ran the exe in a cmd window,
and used the window menu to paste that huge text file into the
dos window. (the window menu is at the very top left part
of the dos window - it says Restore, Move, Resize, etc.)
It executed the program, and correctly inputted all
required info. I was able to run a thousand runs in about an hour
(rather than several weeks of typing stuff in by hand).
Cheers,
bob
|
|
|