Passing variables between automations/scripts

Context

I’m attempting to create a hacky solution to the problem of not being able to toggle recordings with the camera service on demand, the main discussion of which is in this thread. It’s actually quite trivial to create an automation that triggers a recording with a high length setting and then use a second automation to stop/start the first one when a condition has been met, however, there is one major drawback to this approach: the .tmp extension at the end of the resulting file.

My original plan was to use some shell scripting shenanigans to scan for files not open by a process and remove the .tmp extension on anything that matched, though I pretty quickly abandoned that idea due to it being a bit too hacky.

TLDR

The filename variable used by the camera.record is resolved in the first automation:
/media/recordings/{{ now().strftime("%Y-%m-%d-%H:%M:%S") }}.mp4
to:
/media/recordings/2025-05-10-17:28:41.mp4

If there’s a way I can pass the resulting filename to a second automation or even a script that then runs the shell script then that would by far be the ideal fix.

You can pass variables to a script.