<p>Hi this is a fairly common problem in bash. It has nothing to do with Cardano-cli and can be thought of as the general problem of automating password-based authentication for applications via bash scripts.</p>
<p>I did something similar to this using <a href="https://stackoverflow.com/questions/67570700/how-do-i-automate-a-remote-login-with-a-bash-script">https://stackoverflow.com/questions/67570700/how-do-i-automate-a-remote-login-with-a-bash-script</a></p>
<p>if you have any problems feel free to reach out I will happily take a look at your code and fix the bug.</p>

CC BY-SA 4.0
2022-07-02T22:14:55.787Z
2022-07-02T22:14:55.787Z
KryptoKing
<p>In shell scripting, for something like this you want to use <code>expect</code> and <code>send</code>. Here's an example of how we use it for cardano-faucet: <a href="https://github.com/input-output-hk/cardano-faucet/blob/master/nix/nixos/create-faucet-wallet/create-faucet-wallet.sh#L69-L70" rel="nofollow noreferrer">https://github.com/input-output-hk/cardano-faucet/blob/master/nix/nixos/create-faucet-wallet/create-faucet-wallet.sh#L69-L70</a></p>

CC BY-SA 4.0
2022-02-02T20:11:56.530Z
2022-02-02T20:11:56.530Z
Samuel Leathers
<p>I have been experimenting with cardano-cli in the past week. My goal is to find a way to automate sending transactions from multiple wallets in my Daedalus Mainnet.app.</p>
<p>After doing some research, I found: <a href="https://github.com/GimbaLabs/baids-daedalus" rel="nofollow noreferrer">Bash script to send the transaction through cardano-cli</a>. So I followed the instructions on GitHub, and everything was successful.</p>
<p>From here on out, sending transactions from multiple wallets is easy, as I only need to run the function <code>daedalus-cli-send-tx</code> numerous times with different arguments each time. Here's what I've got so far:</p>
<pre><code>$ cat test.sh

#!/bin/bash
echo Please enter sender address:
read sender
echo $sender

daedalus-cli-send-tx wallet1 1000000 $sender #sending from wallet1 with 1ADA to sender
daedalus-cli-send-tx wallet2 1000000 $sender #sending from wallet2 with 1ADA to sender
</code></pre>
<p>And I also made a text file to redirect my input from <code>test.sh</code> to this input file:</p>
<pre><code>$ cat input
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3 #sender address
8736867242 #wallet1 passphrase
1932862497 #wallet2 passphrase
</code></pre>
<p>But when I redirect my input, here's what I get:</p>
<pre><code>$ source ~/test.sh &lt; input

Please enter sender address:
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3
Please enter your passphrase: **********
The given encryption passphrase doesn't match the one I use to encrypt the root private key of the given wallet: 890483bc9ec5c5bfc7d612d9cad885df199c3533
Please enter your passphrase: cardano-wallet: &lt;stdin&gt;: hGetChar: end of file
</code></pre>
<p>Note that I purposely used a wrong passphrase for both transactions, but the first one actually read the input from the text file, so that isn't the problem. The problem lies in that the second transaction asked for a passphrase, yet it returned this line:</p>
<pre><code>Please enter your passphrase: cardano-wallet: &lt;stdin&gt;: hGetChar: end of file
</code></pre>
<p>Even though the <code>input</code> textfile supplies both passphrases.</p>
<p>I have very little knowledge of shell script, so I am asking for help here. What is this error <code>cardano-wallet: &lt;stdin&gt;: hGetChar: end of file</code> (AFAIK it is because the input was not captured), and how do I actually automate entering my passphrase when prompt?</p>

<cardano-cli><cardano-node><daedalus>
Failed to automate entering spending passphrase through 'cardano-cli'
# Failed to automate entering spending passphrase through 'cardano-cli'

(Asked by: username_0 on 2022-02-02)

I have been experimenting with cardano-cli in the past week. My goal is to find a way to automate sending transactions from multiple wallets in my Daedalus Mainnet.app.
After doing some research, I found: Bash script to send the transaction through cardano-cli. So I followed the instructions on GitHub, and everything was successful.
From here on out, sending transactions from multiple wallets is easy, as I only need to run the function daedalus-cli-send-tx numerous times with different arguments each time. Here's what I've got so far:
$ cat test.sh

#!/bin/bash
echo Please enter sender address:
read sender
echo $sender

daedalus-cli-send-tx wallet1 1000000 $sender #sending from wallet1 with 1ADA to sender
daedalus-cli-send-tx wallet2 1000000 $sender #sending from wallet2 with 1ADA to sender

And I also made a text file to redirect my input from test.sh to this input file:
$ cat input
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3 #sender address
8736867242 #wallet1 passphrase
1932862497 #wallet2 passphrase

But when I redirect my input, here's what I get:
$ source ~/test.sh < input

Please enter sender address:
addr1q8sypyrh63y6pgjq0ys0j7rkj2qjun6wnq4haj9d945d9cqu7krtq8wjazqvqxmtmmmyx20kuftmg0578npzdpy3vkasyjn3p3
Please enter your passphrase: **********
The given encryption passphrase doesn't match the one I use to encrypt the root private key of the given wallet: 890483bc9ec5c5bfc7d612d9cad885df199c3533
Please enter your passphrase: cardano-wallet: : hGetChar: end of file

Note that I purposely used a wrong passphrase for both transactions, but the first one actually read the input from the text file, so that isn't the problem. The problem lies in that the second transaction asked for a passphrase, yet it returned this line:
Please enter your passphrase: cardano-wallet: : hGetChar: end of file

Even though the input textfile supplies both passphrases.
I have very little knowledge of shell script, so I am asking for help here. What is this error cardano-wallet: : hGetChar: end of file (AFAIK it is because the input was not captured), and how do I actually automate entering my passphrase when prompt?

**Tags:** cardano-cli, cardano-node, daedalus

---

## 2 answers

### Answer by username_1 on 2022-07-02. Score: 0

Hi this is a fairly common problem in bash. It has nothing to do with Cardano-cli and can be thought of as the general problem of automating password-based authentication for applications via bash scripts.

I did something similar to this using <https://stackoverflow.com/questions/67570700/how-do-i-automate-a-remote-login-with-a-bash-script>

if you have any problems feel free to reach out I will happily take a look at your code and fix the bug.


---

### Answer by username_2 on 2022-02-02. Score: 0

In shell scripting, for something like this you want to use `expect` and `send`. Here's an example of how we use it for cardano-faucet: <https://github.com/input-output-hk/cardano-faucet/blob/master/nix/nixos/create-faucet-wallet/create-faucet-wallet.sh#L69-L70>


---

