0
votes

I asked this question on the Informatica forums, but no one knew the answer, so now I'm coming here for some help.

To my understanding, anything in a "post-session success command" field should be passed to the appropriate command interface and executed. However, when I use an IF statement, it fails. Any ideas?

"IF 1==1 echo.bob >> f:\filename.txt"

This works when I type it manually into the terminal (DOS in this case). But when I throw it into a reusable command task, I get this:

ERROR
POST-SESS
CMN_1949
Error: [Pre/Post Session Command] Process id 2996. The shell command failed with exit code 1.

PS: Using 9.5.1 Hotfix 1

1
welcome to stackoverflow! - Corley Brigman
Thanks! I search this place all the time; finally found a question not already answered and had to sign up - Taejang
I would guess on a rights issue. When yoy say you tried it manually, did you actually log in on the server using the same logon as informatica integration server uses? - whetstone
@Marek: echo.bob echoes on a new line. The command task works great without the IF statement. - Taejang
@wetstone: I didn't log in to the server and try it there; I ran the command on my own terminal. However, using the Informatica user, and on the Informatica server, I can successfully echo to the file mentioned, so it shouldn't be file or folder permissions. Even created a new file, so it wasn't write blocked. Not sure what other permissions could interfere. - Taejang

1 Answers

0
votes

I think the problem is not in how Informatica executes commands. The problem lies in how DOS return error codes, and specifically that some commands, like IF and ECHO does'nt. (The return code Informatica picks up from DOS can be seen with echo %ERRORLEVEL% in DOS, and I'll use the name DOS here for convenience even though under Windows now this is'nt strictly correct)

Run these commands in succession:

REM "cd" sets ERRORLEVEL => ERRORLEVEL is set to 0
cd c:\
echo %ERRORLEVEL%

REM "echo" does not set ERRORLEVEL => ERRORLEVEL is left unchanged 
echo.bob >> c:\filename.txt
echo %ERRORLEVEL%

REM "echo" does not set ERRORLEVEL => ERRORLEVEL is left unchanged 
echo.bob >> c:\thisdirdontexist\filename.txt
echo %ERRORLEVEL%

The first CD set a return code, in this case to 0.
The following ECHO (with or without the IF test) does not change the return code, thus it remains 0 even though the last ECHO fails.

If the first CD command would have returned an error;

@echo off
REM "cd" sets ERRORLEVEL => ERRORLEVEL is set to 1
cd xxxxxx
echo %ERRORLEVEL%

then all the subsequent ECHO would return 1 and Informatica would fail them both.

This said it is still strange since each post-session success command in Informatica is executed under its own cmd-shell, so the initial ERRORLEVEL for every command should allways be 0. I can't explain that and unfortunately I can't actually test this in Informatica as we run under UNIX, but I'm pretty sure this is at least part of the problem.

To get around the problem you should make sure that you set the "Fail task if any command fails" option on the property-tab. This makes Informatica use the cmd/c option and since this set a proper return code Informatica should be able to pick up the error (or success) correctly. If this still doesn't work properly try change the command yourself to:

 cmd /c "IF 1==1 echo.uncle >> c:\filename.txt"