Page 1 of 1

Running a .bat file from Execute Command Fails

Posted: Wed Mar 19, 2014 12:24 pm
by Seyed
Hi all,
I am trying to run a .bat file from an execute command stage in a job sequence. I keep getting the 'The system cannot find the file specified' message. This is even after I fully qualify the file. Does anyone know what I am doing wrong?

Here is what I have put in the 'ExecCommand' tab in the Execute Command stage. I even tried it by putting the entire line inside single or double quotation marks.

Code: Select all

D:\DataStageProcessing\AFS\Output\TableCompare1.bat
Below is the error message that is resulted:

Code: Select all

@Execute_Command_9): Executed: D:\DataStageProcessing\AFS\Output\TableCompare1.bat
Reply=1
Output from command ====>
The system cannot find the file specified.
Thank you for your help,

Seyed

Posted: Wed Mar 19, 2014 12:51 pm
by chulett
What drive letter is DataStage installed on - something other than D:?

Posted: Wed Mar 19, 2014 1:15 pm
by Seyed
Hi Craig,
Thank you for your help. I just checked, the installation is also on D:\ drive but on D:\DataStage7.5 folder.

Seyed

Posted: Wed Mar 19, 2014 1:49 pm
by chulett
Wanted to check as you can't execute a command on a drive letter without switching to that drive first. What does the .bat do? Guessing the error is from an internal step as the error would be different if it wasn't finding the batch file itself:

Code: Select all

'whatever' is not recognized as an internal or external command, operable program or batch file.

Posted: Wed Mar 19, 2014 2:31 pm
by Seyed
Hi Craig,
Thank you for the information. I checked errors on the server's event viewer and didn't notice any errors that coincides with the time I tried running the job sequence.

Here is the content of the .bat file.

Code: Select all

type tableNotFound1.txt | find /v /c "ZZZZZZ" > alpha.txt
Thanks again,

Seyed

Posted: Wed Mar 19, 2014 2:54 pm
by chulett
The type function can't find "tableNotFound1.txt" - fully path it or "cd" to the directory where it lives first to use that relative path.

Posted: Wed Mar 19, 2014 9:27 pm
by chulett
Just to complete this, the CWD or Current Working Directory of any running job is the base Project directory of the job. That is where it is looking for your file.

Posted: Thu Mar 20, 2014 7:21 am
by Seyed
Hi Craig,
Thank you for helping me with this. With help from your input, I was able to resolve this issue by doing the following:

In the job sequence:
In the Execute Command stage, I typed the following in the 'Command' box,

Code: Select all

\\servername\d$\DataStageProcessing\AFS\Output\TableCompare1.bat
In the .bat file:
Next, I did a remote desktop to the server and then using Windows Explorer, I located the .bat file 'TableCompare1.bat' and changed the line to the following:

Code: Select all

type D:\DataStageProcessing\AFS\Output\TableNotFound1.txt | find /v /c "ZZZZZZ" >  D:\DataStageProcessing\AFS\Output\alpha.txt
These changes solved this problem.

Thanks as always for helping us in this Forum.

Continued Success,

Seyed