Maybe I’m not following … but how could you write a script that doesn’t prompt for a key, but also somehow has the key without writing that key somewhere (either to a config, or in a script)?
With the right permissions writing the key to a file shouldn’t be a problem, if that is the concern.