Reputation: 171
I am currently writing a simple expect
script to open up the ethereum geth console
and execute the following commands:
#!/usr/bin/expect
spawn /usr/bin/geth --testnet console
expect ">"
send "personal.unlockAccount('0xdc85a8429998bd4eef79307e556f70bb70d8caf1','X');\r"
expect "true"
expect ">"
send "var mortalContract=web3.eth.contract([{constant:!1,inputs:[],name:'kill',outputs:[],type:'function'},{constant:!1,inputs:[],name:'cashOut',outputs:[],type:'function'},{inputs:[],type:'constructor'}]),mortal=mortalContract['new']({from:'0xdc85a8429998bd4eef79307e556f70bb70d8caf1',data:'60606040525b33600060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055505b61016e8061003f6000396000f360606040526000357c01000000000000000000000000000000000000000000000000000000009004806341c0e1b514610044578063793cd71e1461005357610042565b005b6100516004805050610062565b005b61006060048050506100f6565b005b600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614156100f357600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b5b565b60003073ffffffffffffffffffffffffffffffffffffffff16319050600060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16600060028304604051809050600060405180830381858888f19350505050505b5056',gas:47e5},function(f,t){console.log(f,t),'undefined'!=typeof t.address&&console.log('Contract mined! address: '+t.address+' transactionHash: '+t.transactionHash)});\r"
expect "undefined"
expect ">"
send "exit\r"
expect eof
The compiler has an issue with line 7 (the one starting with var mortalContract
). I searched around and found that double quotes within double quotes will disturb expect so I changed the double inner quotes to single ones yet it still doesn't work and returns the following error:
extra characters after close-brace
while executing
"send "var mortalContract=web3.eth.contract([{constant:!1,inputs:[],name:'kill',outputs:[],type:'function'},"
(file "expectScript.js" line 7)
Upvotes: 1
Views: 1189
Reputation: 246774
Square brackets are special syntax in Tcl. They are like backticks in the shell: execute the command contained within and replace with the result. Like the shell, double quotes allow command substitution. I would use Tcl's non-interpolating quotes, which are curly braces:
send {var mortalContract=web3.eth.contract([{constant:... '+t.transactionHash)});}
# ...^...........................................................................^
send "\r"
Upvotes: 1