Author Topic: Can I automatically run and unlock Graphene cli_wallet using .sh?  (Read 1429 times)

0 Members and 1 Guest are viewing this topic.

Offline xeroc

  • Board Moderator
  • Hero Member
  • *****
  • Posts: 12922
  • ChainSquad GmbH
    • View Profile
    • ChainSquad GmbH
  • BitShares: xeroc
  • GitHub: xeroc
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

Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
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!
Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop

Offline alt

  • Hero Member
  • *****
  • Posts: 2821
    • View Profile
  • BitShares: baozi
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
« Last Edit: September 28, 2015, 04:51:05 am by alt »

Offline clayop

  • Hero Member
  • *****
  • Posts: 2033
    • View Profile
    • Bitshares Korea
  • BitShares: clayop
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.
Bitshares Korea - http://www.bitshares.kr
Vote for me and see Korean Bitshares community grows
delegate-clayop