0

This is supposed to be pretty straightforward however, seems to be not.

I am trying to use --exec and --preload options with geth. --preload options seems to work sometime. But suddenly started giving problem.

*Fatal: Failed to start the JavaScript console: “customcommands.js”: open “customcommands.js”: no such file or directory.*

I tried this command..

*geth --datadir firstserver --networkid 2017 --jspath "." --preload “customcommands.js” --unlock 0 --password pwd.txt --rpcport 8545 --rpcaddr 0.0.0.0 --port 8000 --rpc --rpcapi="admin,db,eth,net,web3,personal" --maxpeers 3 --nat="any" --nodiscover --rpccorsdomain "*" console*

my directory listing says

-rw-r--r--   1 rahulgolash  staff    10 16 Nov 13:32 pwd.txt

drwxr-xr-x  11 rahulgolash  staff   374 16 Nov 14:33 ..

-rw-r--r--   1 rahulgolash  staff    52 16 Nov 19:21 account.txt

-rw-r--r--   1 rahulgolash  staff   570 16 Nov 19:33 genesis.json

-r--r--r--   1 rahulgolash  staff  8241 16 Nov 19:39 customcommands.js

drwxr-xr-x  12 rahulgolash  staff   408 16 Nov 19:40 .

drwx------   6 rahulgolash  staff   204 18 Nov 11:24 firstserver

geth --jspath "." --exec 'loadScript("customcommands.js")' never worked for me! Is this option work only with geth attach command or with geth as server node as well?

Please note that I have already gone thru https://github.com/ethereum/go-ethereum/wiki/JavaScript-Console

2
  • 1
    If you copied and pasted this exactly, then your problem is with the quotation marks around the customcommands.js file name. If you look carefully you will see that they are not straight ascii double quotes like all your other ones, but some other non-ascii variants. I bet this is the problem, but apologies if not! Nov 18, 2017 at 14:22
  • Yes! I realised this was the issue!! Thanks @benjaminion. My another query is on --exec 'loadScript("customcommands.js")' Any comment there please?
    – golra03
    Nov 21, 2017 at 2:46

1 Answer 1

3

Promoting this to an answer...

If you copied and pasted this exactly, then your problem is with the quotation marks around the customcommands.js file name. If you look carefully you will see that they are not straight ascii double quotes like all your other ones, but some other non-ascii variants.

As for --exec, it works only with attach or console. If you have a Geth instance running, you can do something like this:

geth --exec 'loadScript("script.js")' attach ipc:geth.ipc
1
  • Hi @golra03 - did this answer your question? If so it would be good to mark it as answered for the benefit of others. Dec 4, 2017 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.