You don't need to write any custom Bitcoin scripts (in the Bitcoin scripting language) in order to automate creation of transactions. Don't waste your time with the former; just use the bitcoin-cli as shown by seoincorporation and invoke it from your shell script or whatever programming language you prefer.
Alternatively, you could use the Bitcoin Core RPC interface through JSON-RPC calls from any programming language:
https://developer.bitcoin.org/reference/rpc/index.html
For createrawtransaction, it would be:
curl --user myusername --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "createrawtransaction", "params": ["[{\"txid\":\"myid\",\"vout\":0}]", "[{\"address\":0.01}]"]}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
Instead of curl, you can use your chosen programming language's preferred framework to build and send a POST request.