the logging ends only after giving 'exit 0' in the bottom, but this 'exit 0' also terminates and closes the unix session, but my need is to have the control in next command prompt.
exec does not start a new shell, but if i dont give exit 0 at the bottom it hangs (logs including the new promt)
$ uname -a
Linux jasmine 2.6.16.60-0.54.5-smp #1 SMP Fri Sep 4 01:28:03 UTC 2009 x86_64 x86_64 x86_64 GNU/Linux
$ echo $SHELL
/bin/bash
Yes i run using dot & space. it is individual program(but no problem when run via master program bcos master pgm run diff machine), i am just logging echo stuffs and other for debugging purpose.
The 'return' also leads to hang, and but log is ok including 4 prompt lines at the end.
Is there any alternate way to establish log without exec & exit.
I am using this logic for 4 inividual scripts (bash) that runs daily, two of them are for sqlldr and others calling SP., I have to login putty 4 time to accomplish this.
@Scrutinizer
Thanks.
Never found a use for " exec > $LOGFILE 2>&1 " but I see from the link you post how it might work but I cannot match the syntax used by the O/P with any of the examples.
We use "exec" to lock people into a shell menu (which does start a new shell). Any lines in the calling script below the "exec" line are never executed and the "drop-through" in the exec'd shell menu logs you out. That's what I though was happening to the O/P.
redirecting to some o/p file on each single stmt may not be appropriate. I tried to simulate in simple code but again it quits the session after execution...
pls see below
With dot space you are "sourcing" the commands in the script, which mean you execute them in your current environment, which is your interactive shell. The exit statement exits the shell which is your interactive shell, so your putty session gets terminated...
The other way is called executing and in this case a new shell is started in which the script is run. Once it exits, it only exits that shell and your interactive shell remains active...