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.