Geth Testnet – How to Call `geth attach` without Full Path

go-ethereum

I want to connect to my running geth --testnet.

If I run geth --testnet attach, just like geth attach I get :

Fatal: Unable to attach to remote geth: dial unix /user/.ethereum/geth.ipc: connect: no such file or directory

Which is normal, because geth.ipc is not in .ethereum but in .ethereum/testnet.

Is there a way to use an option to make geth look for geth.ipc in the right folder when I'm using the testnet ?

It can be a little heavy to write full ipc path every time (Right now I use geth attach ipc:/path/to/ipc and often start it by hand).

Edit:
I found an open issue on github that suggests there is no way to use options with attach yet. I'm now only asking for ways to do it faster than writing full path.

Best Answer

I have an alias on my computer (Linux) that lets me do this quickly. I just put

alias gat='geth attach ipc://${HOME}/.ethereum/testnet/geth.ipc'

in my .bashrc.

You could also, alternatively, alias geth itself, i.e.

alias geth='geth --ipcpath ipc://${HOME}/.ethereum/geth.ipc'

so that the ipc file is placed in the default location regardless of which network you are using. You can always call \geth --args if you want to use the raw command without the alias.

On windows, I believe you can use

doskey gat=geth attach ipc://%APPDATA%\Ethereum\geth.ipc or something of the sort