3

I want to run a script using the cli wallet. I know can use the --password and --command arguments to the cli, but sometimes the wallet will still prompt for input (passwords/confirmation etc.). Is there a way to configure the wallet to avoid this when running a non-interactive script?

2

If you can predict the questions you are expecting the command to require an answer to, then on Mac/Linux you can simply pipe in a list of answers. E.g.

monero-wallet-cli < echo -e "response1\nresponse2"

However, this could be brittle if changes are made to monero-wallet-cli. The best option is therefore to use the Monero RPC interface, and to use something like jq to extract fields from the response.

  • I guess this could work. As far as I can see, however, I cannot be sure which answers are needed. For example, the refresh command sometimes requires password and sometimes not. – PyrolitePancake May 29 at 11:36
  • @PyrolitePancake yes that's a good point. The right way to do this is with the RPC interface. Most people performing automated tasks would want the wallet running in the background all the time, so that when it's time to make a transaction, they don't have to wait for a refresh before they can create their transaction. There is nothing to stop you temporarily starting the RPC listener just to execute a few commands, at which point you can shut it down in your script. – knaccc May 29 at 11:57
  • You could make use of set ask-password 0 to disable password prompts on an opened wallet. Also you can make use of the linux tool expect to script monero-wallet-cli, but the most sensible thing is to use monero-wallet-rpc. – jtgrassie May 29 at 12:07
  • I guess wallet-rpc is the right way to do it. Its just a shame because the wallet commands are a simpler to use. – PyrolitePancake May 29 at 12:24
  • Btw. I had to do echo -e "response\n" | ./monero-wallet-cli to have this work. – PyrolitePancake May 31 at 8:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.