First off have you attempted this your self?
second there is a way i know of that you can get it but please attempt doing this your self then we will help you,
also it depends on the OS you are running from what i think you are using try:
the history command in *nix.
also posting your script may help users understand what you want.