parent process needs to wait

I have two scripts lets say A.expect and B.sh needs to be executed.
I am executing B.sh from A.expect where B.sh has sleep command.
My problem is that when B.sh encounters the sleep command my A.expect starts executing and exits.
but my A.expect should execute only after completing B.sh.
Is there any solution to this problem without using sleep command in A.expect.
:wall:

Please show your scripts. Specially the part of "A.expect" where you have called "B.sh" and part of "B.sh" where "sleep" has been used.

One solution would be to get the PID of the sleep command and check for the existence of that process id using ps -p <pid> and loop it until this process id exists. Here is a script similar to the your scenario..Since i give the sleep command in background, the rest of the line would be executed without waiting for the sleep to complete. To avoid this i get the PID of sleep command and loop it until you have the required count

#!/bin/ksh

echo "Sleep for 30 seconds in background.."
sleep 30 &
GET_PID=$(ps -ef| awk '$8~/sleep/{print $2}')
echo "Sleepy id is: $GET_PID"

while [ $(ps -p $GET_PID |wc -l) -eq 2 ]
do
        echo sleeping fot 5 sec
        sleep 5
done

echo "calling another_script.sh" # After 30 seconds of sleep rest of the lines are executed
/mkt/michael/another_script.sh

Thanks for your help.
The issue is fixed now.
In my earlier script I was calling the B.sh from A.expect as
send [the path tot he directory]B.sh
Replaced send wit system and it working now.