Running a .bat file from Execute Command Fails

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Running a .bat file from Execute Command Fails

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

What drive letter is DataStage installed on - something other than D:?
Last edited by chulett on Wed Mar 19, 2014 1:44 pm, edited 1 time in total.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post 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
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post 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.
-craig

"You can never have too many knives" -- Logan Nine Fingers
Seyed
Participant
Posts: 74
Joined: Wed Apr 14, 2010 7:25 am
Location: Oklahoma City

Post 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
Post Reply