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 from 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
#On another terminal.
printf "%s\n" "net" >> sudo program.pipe
Thank you for your valuable time and help.
geth
is that it provides an RPC and IPC interface so that you don't need to do anything crazy like this...geth
to call my contracts ( ex:mycontract.get_name()
) which are already deployed into my private blockchain or check transaction receipts (eth.getTransactionReceipt(<hash-id>)
) and so on. So I just want to write a simple script (calling my contracts, sending transactions etc.) that would talk with my blockchain. [This might be an example on tests/test.py code part inpopulus
]. Should I use another useful application to to this task?