It sound like you probably want to use an event script rather than an off-box script. I'm not familiar with the Junos DHCP functionality. Is there a syslog message generated in response to a DHCP binding? If so, then the event script could run automatically, gather the new binding, and write it to an external output file, but if there is no event generated then you'd have to do a time-based event and check the DHCP bindings every X minutes.
Recently I was given the requirement to export all of the DHCP bindings for public customers. This is kind of daunting as I have about 35 SRX-210 routers so manually is kind of out of the question. I am hoping that JunosScript can help.
I am unfamiliar with how JunosScript works so if someone can point me in the right direction here is what I am looking to do:
Trigger: dhcp binding created
Action: Export MAC address, IP address, and Time to external file (Appended of course)
I can then parse the external file into a mySQL database since I'm assuming that exporting directly into the database (something that would be awesome if possible) is not terrible within the realm of possibility.