After-job routine calls unix command 'sed'

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
ebmusa
Participant
Posts: 8
Joined: Fri Oct 05, 2007 3:38 pm

After-job routine calls unix command 'sed'

Post by ebmusa »

Does anyone know why after-job routine ExecSH does not work on unix command like --> sed "s/a/b/g" <input.txt >output.txt ??

This command works fine if I run it on the command line.

Thanks.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

:? What doesn't work about it? If I had to guess, I'd assume it is because you are using relative file paths...
-craig

"You can never have too many knives" -- Logan Nine Fingers
ebmusa
Participant
Posts: 8
Joined: Fri Oct 05, 2007 3:38 pm

Post by ebmusa »

The command uses absolute path. The command does not work because there is no output.txt file created, and there is no output from the DSExecute("UNIX",..,output,msg) function to tell what went wrong.

Thanks,
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Your 'example' shows a relative path, hence the guess. First you mentioned ExecSH and now DSExecute. Please post the exact syntax you are using to execute whatever command you are running.

:idea: DSExecute returns information in the two variables you name at the end of the call - check the docs. For what you posted, 'output' would be the name of a variable that captured anything echoed to standard out by the script/command and 'msg' would be a variable that captures the exit code from the script/command.

And what is ".." for the UNIX command to actually execute supposed to mean? :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ebmusa
Participant
Posts: 8
Joined: Fri Oct 05, 2007 3:38 pm

Post by ebmusa »

Sorry for not clearly explained my situation.

If you look at the built-in source code for routine ExecSH, it actually calls the DSExecute() function to execute the unix command. the output and msg (or should I say returncode) can be used for capturing what is going on. These two arguments returned nothing in my case.

I guess what I try to ask is if anyone has used the sed command successfully. for instance, I had experience that ExecSH complained the command $(date) but not `date`

Thank you very much for your reply!
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Again, best if you post your actual syntax. There should be no issues calling any operating system command but seeing your syntax and any errors generated would be helpful in figuring out what is going on.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ebmusa
Participant
Posts: 8
Joined: Fri Oct 05, 2007 3:38 pm

Post by ebmusa »

Here is the exact input value for Afater-Job Routine ExecSH I used:

sed "s/a/b/g" < #FilePath#/input.txt > #FilePath#/output.txt
where #FilePath# is /dir1/dir2/dir3

I can see in the job log that the #FilePath# is expanded correctly, but there is nethier error messages nor output.txt file being generated.

Thanks,
lstsaur
Participant
Posts: 1139
Joined: Thu Oct 21, 2004 9:59 pm

Post by lstsaur »

I did a sed 's/a/b/g' < /tmp/input.txt > /tmp/output.txt in my job's After-job subroutine and it produces expected results.

Try use single quote and hard-coded the path.
Ronetlds
Participant
Posts: 28
Joined: Thu Mar 30, 2006 12:48 pm

Post by Ronetlds »

Call DSExecute("UNIX", sed 's/a/b/g' < /tmp/input.txt > /tmp/output.txt , output, systemreturncode)
ebmusa
Participant
Posts: 8
Joined: Fri Oct 05, 2007 3:38 pm

Post by ebmusa »

yahooooo! It works. Thank you so much :P
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

So, what actually fixed it for you? The switch to single quotes? Were you still able to levelage your file path parameters?
-craig

"You can never have too many knives" -- Logan Nine Fingers
ebmusa
Participant
Posts: 8
Joined: Fri Oct 05, 2007 3:38 pm

Post by ebmusa »

The single quote solved my problem. Although using both double and single quotes work fine on the unix command line, but I guess DataStage only likes the single quote.

Yes, the file path parameter stays the way as it was.

Thank you all again :P
Post Reply