Program not running from a batch file

Hello,

I have a batch file that calls a program to do a database backup. If I run it from the command line, it will run fine, but it will not run from my batch file. The code being used is the following:


SET BATLOGFILE=D:\CTSQL\BACKUPS\CT.log

rem Get the day, month and year
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set weekday=%%a& set tmonth=%%b& set tday=%%c& set tyear=%%d)
IF "%BATLOGFILE%" == "" SET BATLOGFILE= D:\CAFETERMSQL\BACKUPS\CAFETERM.LOG
echo ------------------------------------------------- >> %BATLOGFILE%
echo OPEN >> %BATLOGFILE%
echo C:\PROGRA~1\FIREBIRD\FIREBIRD_1_5\BIN >> %BATLOGFILE%
echo D:\CAFETERMSQL\BACKUPS >> %BATLOGFILE%
Date /T >> %BATLOGFILE%
Time /T >> %BATLOGFILE%


rem ========= Step 4: backup database =========
echo backup Database... >> %BATLOGFILE%

C:\"Program Files"\FIREBIRD\FIREBIRD_1_5\BIN\gbak -B -user USERID -password USERPASS    localhost:D:\CT\CT033105.FDB D:\CT\BACKUPS\CT.bck 2> errout.tmp
echo 1> nul 2> empty.tmp
echo N 1> N_CR.tmp
comp errout.tmp empty.tmp 1> nul 2> nul < N_CR.tmp
if errorlevel 1 GOTO NOT_BACKEDUP
echo backup CT.FDB ok >> %BATLOGFILE%
...

the gbak is not being executed. I am having the same problem in another machine, but the strange thing is that it was running correctly in that machine until one day when it would not run.
Thank you
hcarvajalAsked:
Who is Participating?
 
Andrep23Commented:
What is, when you make this first:

cd C:\"Program Files"\FIREBIRD\FIREBIRD_1_5\BIN\

and then:

gbak -B -user USERID -password USERPASS    localhost:D:\CT\CT033105.FDB D:\CT\BACKUPS\CT.bck 2> errout.tmp
0
 
yronnenCommented:
Just a wild guess, but maybe you should try executing the backup app like this:

start /wait "C:\Program Files\FIREBIRD\FIREBIRD_1_5\BIN\gbak" -B -user USERID -password USERPASS    localhost:D:\CT\CT033105.FDB D:\CT\BACKUPS\CT.bck 2> errout.tmp
0
 
hcarvajalAuthor Commented:
No, it did not worked. In the log file I get the messages:

backup Database...
backup CT.FDB ok

but there is no backup file.
thanks.
0
 
hcarvajalAuthor Commented:
before the cd C:\"Program Files"\FIREBIRD\FIREBIRD_1_5\BIN\  I had to add
c:
and it worked.
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.