Error while executing sh command

Hi,
I have 2 files temp1.sh and temp2.sh as follows:

temp1.sh

echo "session1"
sh temp2.sh
echo "exit session2 and enter session1"

=================================

temp2.sh

echo "session2"
sh 
echo "exit session2"

=================================
when i execute the temp1.sh script file (sh temp1.sh)
i need the output as

session1
session2
exit session2
exit session2 and enter session1

=============================
but i get the output as

session1
session2

==============
After executing "sh" line in temp2.sh, it is coming out from the parent script(temp1.sh)Please help me on this....
thanks!

Is there any use of the sh command inside the temp2.sh ? If not remove that one and run the script.

sh without any arguments will read commands from stdin. If you have not redirected stdin, it's waiting for your input at the terminal. Typing control-d will send EOF (end of file) and sh will exit, resuming the script.

Aside from possibly executing some startup files, sh < /dev/null should not do anything at all; when it attempts to read a command from stdin, it immediately sees EOF. Seems rather pointless.

Regards,
Alister

As alister explains, the free-standing sh has started a clean interactive shell. To get out of it, type exit or the control code for end-of-file (usually ctrl/D ) .
See stty -a to find out the control code for end-of-file on ypur terminal.

Thanks for the replies!..

"command sh" is used to create a trusted sesion ID (which is called from .exe)to execute a batch file.. so sh command is necessary and cannot remove that line..is there any other way to get the exact o/p?(the code given above is just a dummy code..actual code is different)

I have no idea what you're talking about. "Dummy code" is usually a waste of everyone's time.

Regards,
Alister