I'm trying to programmatically connect to a JavaScript console (just like you get with geth attach
) using the geth.ipc file that gets created in the chaindata folder. On Linux, it's a socket file, so I figured I could connect to it with something like this (in Python):
import socket
client = socket.socket( socket.AF_UNIX, socket.SOCK_STREAM )
client.connect("/home/john/Desktop/EthPrivateChain/chaindata/geth.ipc")
client.send(str.encode("admin.nodeInfo.enode"))
print(str(client.recv(1024)))
client.close()
However, this gives me the JSON RPC, not the JavaScript console. The code works but the endpoint returns an error when I try this. The same code, but with a JSON request, works. I want the JavaScript console because I want to be able to access some stuff that isn't available through the JSON RPC, specifically the enode in this case. I think there has to be a way to connect to that file this way because I can use it to start a console with geth attach /home/john/Desktop/EthPrivateChain/chaindata/geth.ipc
. Is there some way I can make this socket file access the JavaScript API when I access it with my own code?