Right the approach of storing the SID in a file works just fine, subject to some things to be aware of:
1) There will be a filename collision if multiple scripts invoking mgmt_cli are executing at the same time. The first script drops its SID into the file after authenticating (let's say sid.txt). Another script fires up while the first one is still running and dumps its SID into the same filename, now the first script starts screwing up when it reads the wrong SID. This can cause some very hard to diagnose, random-looking failures. Been there, done that, got the T-shirt.
2) The SID is left lying around in a file; if the session was not properly logged out and SID deallocated, someone (or some script) might be able to use that SID when they should not.
For those reasons, it is recommended to store the allocated SID in an environment variable (like $SID), which will automatically be deallocated when the script finishes, and can't be accidentally used beyond the scope of that one script. Once again these types of best practices are in the new Check Point Certified Automation Specialist R81.20 class.
Gateway Performance Optimization R81.20 Course
now available at maxpowerfirewalls.com