# ... stuff run every time this script is invoked if [ "$checkvar" != "foo" ]; then exec perl /usr/script/myscript.pl else # ... stuff to do after the script has run fi #### $ENV{checkvar}="foo"; exec "sh", "/usr/script/myshell.sh" # or, if you're logging in exec "sh", "-l"