awk doesn't know that anything's wrong, and you only get the return value of the last command.
It's traditional to have whatever runs a persistent program save its PID in a file, so you don't need to resort to ps | grep | awk | kitchen | sink tricks to find out what the PID is. This also allows systems where more than one instance of it can be run independently without interfering with each other.
I guess by your statement its should return the last value which is 1 in my case.
We do not have root access so i am not sure how can I get the PID if not using the ps command. Kindly help if you know an more professional way of achieving this.
What makes you think 1 was the last value? It's the last value that you care about, but it's not the last value, the last one is the one returned by awk. How's it to know anything's wrong if nobody tells it so?