BitShares Forum

Main => Technical Support => Topic started by: clayop on September 28, 2015, 12:48:53 am

Title: Can I automatically run and unlock Graphene cli_wallet using .sh?
Post by: clayop on September 28, 2015, 12:48:53 am
I tried...

Code: [Select]
screen -S cli_wallet cli_wallet --chain-id 0f8b631d7a9dfebf16d6776fab96b629a14429762bf9c3eb95db1e4e4af637a4 -H 127.0.0.1:8092
echo -e "password\n"

but it did not work.
Title: Re: Can I automatically run and unlock Graphene cli_wallet using .sh?
Post by: alt on September 28, 2015, 04:46:19 am
expect is used for this, here is an example
Code: [Select]
#!/usr/bin/expect -f

set chain_id "0f8b631d7a9dfebf16d6776fab96b629a14429762bf9c3eb95db1e4e4af637a4"
set wallet "test_wallet"
set rpc_user "alt"
set rpc_password "alt"
set port "8092"
set unlock_password "thisismypassword"

spawn ./cli_wallet -w $wallet --chain-id $chain_id -H 127.0.0.1:$port -u $rpc_user -p $rpc_password

expect -exact "locked >>> "
send -- "info\r"
expect -exact "locked >>> "
send -- "unlock $unlock_password\r"
expect -exact "unlocked >>> "
send -- "list_my_accounts\r"
interact
wait
Title: Re: Can I automatically run and unlock Graphene cli_wallet using .sh?
Post by: clayop on September 28, 2015, 05:26:46 am
expect is used for this, here is an example
Code: [Select]
#!/usr/bin/expect -f

set chain_id "0f8b631d7a9dfebf16d6776fab96b629a14429762bf9c3eb95db1e4e4af637a4"
set wallet "test_wallet"
set rpc_user "alt"
set rpc_password "alt"
set port "8092"
set unlock_password "thisismypassword"

spawn ./cli_wallet -w $wallet --chain-id $chain_id -H 127.0.0.1:$port -u $rpc_user -p $rpc_password

expect -exact "locked >>> "
send -- "info\r"
expect -exact "locked >>> "
send -- "unlock $unlock_password\r"
expect -exact "unlocked >>> "
send -- "list_my_accounts\r"
interact
wait

Thanks!
Title: Re: Can I automatically run and unlock Graphene cli_wallet using .sh?
Post by: xeroc on September 28, 2015, 05:55:54 am
When listening to 8092 like this:
Code: [Select]
./programs/cli_wallet/cli_wallet -H 127.0.0.1:8092 you can also just use curl:
Code: [Select]
curl --data '{"jsonrpc": "2.0", "method": "call", "params": [0,"unlock",["PASSWORD"]], "id": 0