I'm trying to use a bash file to execute a loasdScript file in geth console on a private blockchain. How can I do this?

I have tried:

\\Bash file

$ geth --exec 'loadScript("/path/to/file/filename.js")' attach ipc:/path/to/ipc

But it doesn't worked.

Also tried:

\\Bash file

geth --preload "/my/scripts/folder/utils.js,/my/scripts/folder/contracts.js" console

But, not worked also.

Hope someone could help me with this.


  • I can't leave this as a comment, but can you please provide more information why the scripts failed to work? – mik Jul 20 '17 at 7:46

I found the solution from the problem through this:

 ./geth --jspath "path/to/file.js" --exec "eth.namereg(loadScript('file.js'))"" attach ipc:folder/geth.ipc

Hope could be usefull for someone.

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.