How to automate this few lines of dos command?

Stalker

Member
Oct 9, 1999
193
0
0
here's the step I usually go through to backup daily data:
C:\>"exp" //start oracle export program
Username: "fin/fin@ora" //oracle export prompt for username
Enter array fetch buffer size: 4096 > "I press enter" //oracle export request
Export file: EXPDAT.DMP > "c:\todaydate\fin.dmp"
"then I press enter (5 times) for rest of the prompt"
 

KB

Diamond Member
Nov 8, 1999
5,406
389
126
Does exp.exe have some command line options you could use to pass an answer file or something similar?
If not the only way I can think of would be to use vbscript and send keys to it.

The following in a .vbs file might work:

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe /K cd.."
Wscript.Sleep(100)
WshShell.AppActivate("C:\WINDOWS\System32\cmd.exe")
Wscript.Sleep(100)
WshShell.SendKeys("cd..{ENTER}")
Wscript.Sleep(100)
WshShell.SendKeys("cd..{ENTER}")
Wscript.Sleep(100)
WshShell.SendKeys("C:{ENTER}")
Wscript.Sleep(100)
WshShell.SendKeys("exp{ENTER}")
Wscript.Sleep(100)
WshShell.SendKeys("fin/fin@ora{ENTER}")
Wscript.Sleep(100)
WshShell.SendKeys("C:\" & Replace(Date(), "\","") & "\fin.bmp{ENTER}")
Wscript.Sleep(100)
WshShell.SendKeys("{ENTER}")
Wscript.Sleep(100)
WshShell.SendKeys("{ENTER}")
WshShell.SendKeys("{ENTER}")
WshShell.SendKeys("{ENTER}")
WshShell.SendKeys("{ENTER}")
 

Crusty

Lifer
Sep 30, 2001
12,684
2
81
Just create a batch file and use the System(..) from C++ to execute the batch.

I think that's right at least...haven't done it in a while.
 

Stalker

Member
Oct 9, 1999
193
0
0
I have tried with batch file but it doesn't do a thing after I start oracle export program.



 

PrincessGuard

Golden Member
Feb 5, 2001
1,435
0
0
You could just make a text file containing what you type and just redirect it, e.g. "exp < commands.txt". However, getting the current date in there isn't easy.
 

Stalker

Member
Oct 9, 1999
193
0
0
I have to export 8 things everyday. Does the file trick let me do 8 different export using one file?
 

skace

Lifer
Jan 23, 2001
14,488
7
81
According to PrincessGuard, something like this would work. But I doubt it and have no way of even testing it. If it did work, you could make it run 8 different parameters in a row easily.