Help in korn shell scripting...

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
vigneshra
Participant
Posts: 86
Joined: Wed Jun 09, 2004 6:07 am
Location: Chennai

Help in korn shell scripting...

Post by vigneshra »

Hi,

How to achieve this? Let us assume the following:

There are 2 scripts a.ksh and b.ksh

$ cat a.ksh
sh b.sh 2>&1 >> /work/log/a_log.txt

$ cat b.sh
echo "abcd"

My requirement is, is there a way to display this abcd in standard output also alongside of writing into a_log.txt?

The catch here is I cannot modify the script a.ksh as there are innumerous shell scripts like a.ksh that call b.ksh. So here I can modify b.ksh alone to achieve the result.

Please suggest if there is anyway to modify b.ksh to output the result to standard output as well.

Please help me out in this. Appreciate your help.
Vignesh.

"A conclusion is simply the place where you got tired of thinking."
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

Not really, since a.ksh completely controls the stderr and stdout of b.sh. The only suggestion I have is to rename b.sh to c.sh. Then, write a new b.sh that does whatever you desire with the stdout of c.sh as well as send it to stdout for a.ksh to handle. Consider looking at the "tee" command.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Instead of redirecting stdout, why not pipe it though the tee command?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
kumar_s
Charter Member
Charter Member
Posts: 5245
Joined: Thu Jun 16, 2005 11:00 pm

Post by kumar_s »

Are you planning to call these shell from datstage and have the stdout in ds log?
If so there are many other aproaches avaialbe.
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
vigneshra
Participant
Posts: 86
Joined: Wed Jun 09, 2004 6:07 am
Location: Chennai

Post by vigneshra »

Hi

Thanks for all your inputs. I want the output to be displayed to stdout as it should be displayed in the system output log of the scheduler. But per Bland, it looks like we cannot do it straight forward as both stdout and stderr are controlled in a.ksh. I think we have to bypass using a 3rd script as per Bland's idea. Please let me know, if there is any other suggestion. Thank you very much again!
Vignesh.

"A conclusion is simply the place where you got tired of thinking."
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

I'm right because you stated you can't modify a.ksh, and that's where you'd have to insert the "tee" without using my suggestion.
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
forboy
Participant
Posts: 13
Joined: Tue May 04, 2004 12:03 pm

Re : Help in korn shell scripting...

Post by forboy »

Basically you issue two commands in a.sh

sh b.sh 2>&1 >> /work/log/a_log.txt
sh b.sh 2

That should do it.

Forboy
forboy
Participant
Posts: 13
Joined: Tue May 04, 2004 12:03 pm

Re : Help in korn shell scripting...

Post by forboy »

oops sorry its



sh b.sh 2>&1 >> /work/log/a_log.txt
sh b.sh

That should do it.

Forboy
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Fairboy,

The OP does not wish to modify a.sh
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
kcbland
Participant
Posts: 5208
Joined: Wed Jan 15, 2003 8:56 am
Location: Lutz, FL
Contact:

Post by kcbland »

But thanks for taking a shot at helping out :)
Kenneth Bland

Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Post Reply