[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

script to display current process PID and return value



 
    
script to display current process PID and return value:

[terrence@igloo terrence]$ cat t.sh
#!/bin/sh

ps 

echo
echo $$ > t.sh.pid
echo -n "PID: "
cat t.sh.pid

RETVAL=$?
echo "return value: " $RETVAL


[terrence@igloo terrence]$ ./t.sh 
  PID TTY          TIME CMD
 9969 pts/1    00:00:00 bash
11817 pts/1    00:00:00 vi
11880 pts/1    00:00:00 t.sh
11881 pts/1    00:00:00 ps

PID: 11880
return value:  0

Google