Can I do something like
> api1.command1() && api2.command2("arg2") && api1.command3()?
Here's how I run my multiple command scripts in Linux and OS/X.
I've created a file
$HOME/bin/multipleCommands.sh with the following contents:
#!/bin/sh geth attach << EOF | grep "RESULT:" | sed "s/RESULT: //" var balance1 = web3.fromWei(eth.getBalance("0x9535b2e7faaba5288511d89341d94a38063a349b"), "ether"); console.log("RESULT: balance1=" + balance1); var balance2 = web3.fromWei(eth.getBalance("0x88a80b35014fe7c33b4568cb818f2e16ba799b23"), "ether"); console.log("RESULT: balance2=" + balance2); EOF
I then set the executable bit for this file using the command
chmod 700 $HOME/bin/multipleCommands.sh
I run the following command to produce the output:
$HOME/bin/multipleCommands.sh balance1=17.431747444329232008 balance2=1.042500854
In Ubuntu, the
$HOME/bin subdirectory will be added to your
$PATH once you log out and then log in. You can then run commands in the
$HOME/bin subdirectory without specifying the
$HOME/bin/ prefix to your command. So the following will work:
multipleCommands.sh balance1=17.431747444329232008 balance2=1.042500854
If you are running Windows, the commands above should work if you install the Cygwin shell.
While you are writing your script and debugging your
geth commands, use the following statement in your script file so you can see the progress of the
geth statements being executed:
# geth attach << EOF | grep "RESULT:" | sed "s/RESULT: //" geth attach << EOF
geth attach << EOF | grep "RESULT:" | sed "s/RESULT: //"