ps returning more process ids

Please help me with this question

I have a tantan.sh under /home/mydir which is a caller to another script "tantan.sh" under /home/anotherdir
-----------------------------------------------------------
/home/mydir/tantan.sh
------------------------------------------------------------

#!/bin/sh

echo "caller script
/home/anotherdir/tantan.sh
exit 0

-----------------------------------------------------------
/home/anotherdir/tantan.sh
-----------------------------------------------------------

#!/bin/sh
echo "actual script"
 ps -ef |grep tantan.sh | grep -v grep|awk '{print $2}'

 for PID in `ps -ef | grep "tantan.sh" | grep -v "grep" |awk '{print $2}'`
                do
                        echo $PID
                done

This always echos 3 PIDs and not two. My requirement is to see, that if there are two or more tantan.sh process initiated, then exit. Only one tantan.sh must be there at any time, parellel processing is not supported.

I was thinking to go this way, if there is any other process other than the currentPID and parent PID, then exit, but since the ps command returns three PIDs, I am not able to get a solution, please advice.

Is the script detecting itself as a running process?

What are you trying to achieve ?
Why are you using 2 scripts instead of just 1 ?

I only get two PIDs outputted, so something else is going on.

What is the full output of:

# ps -ef | grep tantan.sh | grep -v grep

Just to save the last "grep -v grep" pipe ...

# ps -ef | grep [t]antan.sh

Or just use this to get the pid

pidof tantan.sh
ps -ef | grep -w "tantan\.sh" | grep -vw "$$" | grep -vw "grep"