if I understand the question correctly, then analyzeHeadless documentation will help you.
Headless Scripts: Passing Values Between Scripts If you are running
multiple scripts in headless operation and would like to store a value
in one script that is accessible by another script, use the
HeadlessScript methods below. They facilitate the storage and