Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simulating enter in a batch file, won't let me pipe a txt file 1

Status
Not open for further replies.

wibblewobblewow

Technical User
May 12, 2005
2
GB
I am trying to wrtie a batch file that will export my checkpoint firewall database using the upgrade_export.exe. The code i am using is:

upgrade_export.exe c:\backup (c:\backup been the place i want the output to go).

When i run this it asks for the enter key to be pressed to continue. The program will let you type anything and then enter. have tried using the following:

upgrade_export.exe c:\backup < cmds.txt (where cmds.txt has a random word typed in followed by a carriage return)

This results in the following error :

C:\Scripts\CPbackup>upgrade_export c:\backup 0<c:\scripts\CPbackup\cmds.txt
The system cannot find the file specified. same error if i specify the path or not (and the file is there!)

Having searched for a while the only thing people seem to do in this situation is what i have already tried, so i am out of ideas. Any suggestions / shots in the dark would be greatly welcomed

Thanks
 
wibblewobblewow,
I have come to grips that there is no way to simulate a carriage return in a dos batch file....

with that said, there still is hope. I turned to a new language that is very similar to dos. Give this serious consideration.
it is called AutoIT.
(v2 im familiar with)
(just released)

I recommend you look into these links... you still can call dos batch files, but now, you deal with the windows GUI, which you can simulate enters, cancels, radio toggles,etc...

it is a fantastic program, very easy to learn, due to its similarity to dos. Once written in AutoIT you can compile it with one keystroke for anyone to run, or call from another batch file.

i used it to custom software installs without having to lift a finger other than kick off the program.

sounds like to fix your problem it would be a very simple program to write.
hope this helps
ccastelein
 
Thanks ccastelein (loads and loads)

This is a good bit of kit, nice and easy to use, and it will do enter keypress for you.

took me an hour to do my script from install to reading the help to finishing a running script.

Script as follows:

; Script Start - Add your code below here
run ("cmd")
Sleep(500)
send ("c:")
Sleep(500)
send ("{ENTER}")
Sleep(500)
send ("cd\")
Sleep(500)
send ("{ENTER}")
Sleep(500)
send ("cd scripts")
Sleep(500)
send ("{ENTER}")
Sleep(500)
send ("cd CPbackup")
Sleep(500)
send ("{ENTER}")
Sleep(500)
send ("upgrade_export.exe c:\backup")
Sleep(500)
send ("{ENTER}")
Sleep(1000)
send ("{ENTER}")
Sleep(30000)
send ("exit")
Sleep(500)
send ("{ENTER}")

Anyone reading this having done a google search for the same sort of problem i had should download this, it even compiles the final result into an exe, and you can call on it in a batch script. Also the help is v.good and helpful, with short tutorials

Thanks again CC..

wibblewobblewow :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top