You might need to look at using Session Variables within the script in order to achieve that. Refer below video to get an idea, rather than doing it in two different scripts you will need to do all this in a single script i.e., Set Session and Get Session etc:
https://www.youtube.com/watch?v=9HXivETA8bE
You can also refer to Scripting Guides available at below link in order to know more about the Session variables:
http://www.cisco.com/c/en/us/support/customer-collaboration/unified-contact-center-express/products-programming-reference-guides-list.html
Regards
Deepak