I need a way to restart my development environment fresh so I have a little script like this:
quit 'keosd'
quit 'nodeos'
rm -rf eosio
rm -rf ~/eosio-wallet
nohup keosd > keosd.log 2>&1 &
nohup node > nodeos.log 2>&1 &
cleos wallet create --file .Wallet
cleos create key --file .Key
PK=5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3
cleos wallet import --private-key=$PK
PK=$(head -1 .Key |sed 's/Private key: //')
cleos wallet import --private-key=$PK
PK=$(tail -1 .Key |sed 's/Public key: //')
cmd="cleos create account eosio t $PK $PK"
echo $cmd
$cmd
but when the script gets to the last line I get the dreaded error:
Failed to connect to nodeos at http://127.0.0.1:8888/; is nodeos running?
though if I run cleos get info
I can see nodeos is running and curiously, if I run the command by hand (shown below as printed by the script), it works. but the call from the script fails
cleos create account eosio t EOS7Yo3xXD35Ct3Bu9BnwGDR5cUZDscwUtu9Kxc9ywJyJSuUFn2fL EOS7Yo3xXD35Ct3Bu9BnwGDR5cUZDscwUtu9Kxc9ywJyJSuUFn2fL
for completeness:
quit() {
s=$(echo $1 |sed 's/./[&]/') # this trick prevents grep from finding itself
id=$(ps aux |grep $s |awk '{print $2}')
[ ! -z $id ] && kill $id
}
node() {
nodeos -e -p eosio \
--plugin eosio::producer_plugin \
--plugin eosio::chain_api_plugin \
--plugin eosio::http_plugin \
--plugin eosio::history_plugin \
--plugin eosio::history_api_plugin \
--data-dir /Users/ekkis/dev/eos/eosio/data \
--config-dir /Users/ekkis/dev/eos/eosio/config \
--access-control-allow-origin='*' \
--contracts-console \
--http-validate-host=false \
--verbose-http-errors \
--delete-all-blocks \
--filter-on='*'
}
and I'm running on OSX 10.14 (Mojave) with CDT v1.4.1