Skip to main content
1 of 2
alper
  • 8.4k
  • 11
  • 67
  • 155

Could not able to pipe with background geth process

I am working on a bash script, where it will send my commands to geth through a simple piping. The problem is for each piping I have to create geth process again, which preload my_script.js into geth all over again and this process actually consumes time since my_script.js is large.

echo "net" | sudo geth --datadir --preload "my_script.js" \
      "/home/MyEthereumEbloc" attach ipc:/home/MyEthereumEbloc/geth.ipc

Output (I can obtain the output correctly):

>
{
  listening: true,
  peerCount: 2,
  version: "23422",
  getListening: function(callback),
  getPeerCount: function(callback),
  getVersion: function(callback)
}

I want to pass information as input and get its output result with geth process that works at the background and required to load my_script.js only one time. In order to accomplish this I have tried piping but I wasn't able to make it work. I am sorry if this question might be related to unix but any additional approach to solve this problem would be appreciated.

mkfifo program.pipe;
cat > program.pipe &
sudo geth --datadir "/home/MyEthereumEbloc" attach \
      ipc:/home/MyEthereumEbloc/geth.ipc console >> output.txt < sudo program.pipe

Thank you for your valuable time and help.

alper
  • 8.4k
  • 11
  • 67
  • 155