I am trying to create a script running a couple of geth nodes, open a console for each of them and run a couple of commands such as admin.addPeer() and miner.start(). I read that i can use --exec to run javascript files in the console but it does not seem to work for some reason. Here is my code:

start cmd /k geth --targetgaslimit "10000000" --identity "node1"  --allow-insecure-unlock --ipcpath node1 --rpc --rpcport "8000" --rpccorsdomain "*" --datadir "D:\Alexy\Geth Ethereum\node1" --port "30303" --nodiscover --rpcapi "db,eth,net,web3,personal,miner,admin" --networkid 1900 --nat "any" 

start cmd /k geth  --identity "node2"  --ipcpath node2   --allow-insecure-unlock --rpc --rpcport "8001" --rpccorsdomain "*" --datadir "D:\Alexy\Geth Ethereum\node2" --port "30304" --nodiscover --rpcapi "db,eth,net,web3,personal,miner,admin" --networkid 1900 --nat "any"

start cmd /k geth --identity "node3"  --ipcpath node3  --allow-insecure-unlock --rpc --rpcport "8002" --rpccorsdomain "*" --datadir "D:\Alexy\Geth Ethereum\node3" --port "30305" --nodiscover --rpcapi "db,eth,net,web3,personal,miner,admin" --networkid 1900 --nat "any" 

start cmd /k geth  --exec 'loadScript("D:\Alexy\Geth Ethereum\Windows  Scripts\node1.js")' attach

start cmd /k geth attach ipc:\\.\pipe\node2

start cmd /k geth attach ipc:\\.\pipe\node3

I also tried geth attach ipc:\\.\pipe\node3 --exec "miner.start(1); personal.unlockAccount(eth.accounts[0],'pass')" which works, but then I would have to list all commands on 1 line which is not ideal.

  • Hi Aleksi - can you add your node1.js or explain what your are trying to do in that JS file? – Steven V Jan 25 at 19:51
  • @StevenV I haven't really finished the file but I just want to run a couple of initial setup commands such as add all the other nodes as peers (admin.addPeer), unlock some accounts and start mining so that the whole process is automatic – Aleksi Daskalov Jan 26 at 12: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.