I have created a local Ethereum test net. I am using truffle to send transactions to EVM nodes. I have created a bash script that looks as follows (send_transactions.sh):

sudo truffle console  --network ethrpc1
exec ./batch.js
sudo truffle console  --network ethrpc2
exec ./batch.js
sudo truffle console  --network ethrpc3
exec ./batch.js
sudo truffle console  --network ethrpc4

ethrpc1, ethrpc2, ethrpc3, and ethrpc4 are my EVM nodes. The batch.js has the transactions that I send to each of these nodes.


The above bash script stops working after the line "sudo truffle console --network ethrpc1". It opens the truffle console and remains there without executing the rest of the commands in the bash script.

I have got this to work by typing these in my Linux command prompt manually but the shell script does not work. Is there a way to get the above commands to work using a bash script or is there an alternative method to automate sending transactions to multiple nodes without doing it manually?


I am using Ubuntu 18.04.3 LTS AWS EC2 instance

Truffle version: Truffle v5.1.28

  • I would suggest using JavaScript scripting instead of Bash. Here are some examples github.com/Dawn-Protocol/dawn-erc20-erc777/tree/master/src/… – Mikko Ohtamaa Jun 2 at 19:59
  • Yes @Mikka, I am using a script called batch.js that sends transactions. However, I want the batch.js to be executed in several truffle consoles for networks ethrpc1, ethrpc2, ethrpc3, and ethrpc4. That's why I tried to automate this process by writing a bash script. Do you mean to say to use js instead of truffle? – Deepal Jun 3 at 4:23
  • If you know JavaScript, which you probably do, then why not script this inside JavaScript itself as I believe it might be easier. – Mikko Ohtamaa Jun 3 at 12:38
  • Thanks. I got it done with javascript and a shell script coupled with it without using Truffle. The reason that I wanted to use truffle was that there was a truffle docker container connecting to the EVM node in the repo I was using – Deepal Jun 4 at 5:31

Your Answer

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

Browse other questions tagged or ask your own question.