Page 1 of 1

Help in korn shell scripting...

Posted: Tue Jul 04, 2006 6:18 pm
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.

Posted: Tue Jul 04, 2006 6:27 pm
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.

Posted: Tue Jul 04, 2006 8:33 pm
by ray.wurlod
Instead of redirecting stdout, why not pipe it though the tee command?

Posted: Tue Jul 04, 2006 11:41 pm
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.

Posted: Wed Jul 05, 2006 12:02 pm
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!

Posted: Wed Jul 05, 2006 12:09 pm
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.

Re : Help in korn shell scripting...

Posted: Mon Jul 17, 2006 2:48 pm
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

Re : Help in korn shell scripting...

Posted: Mon Jul 17, 2006 2:50 pm
by forboy
oops sorry its



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

That should do it.

Forboy

Posted: Mon Jul 17, 2006 3:12 pm
by narasimha
Fairboy,

The OP does not wish to modify a.sh

Posted: Mon Jul 17, 2006 3:23 pm
by kcbland
But thanks for taking a shot at helping out :)