command issued from within bash script not working

Need help with C, C++, perl, python, etc?

Re: command issued from within bash script not working

Postby PsySc0rpi0n » 2020-06-04 17:18

arzgi wrote:I have nothing to add to what ruwolf and Dai_trying have said, but you know bash only supports integers?

If you know how long would the floating number would be, you could multiply it to get to an integer number.

Above, and the lack of return value in functions are the reasons why I use bash only for starter scripts and like.

Python in my mind too is better for general programming.

I didn't know about that of integers and floats. Anyways, I managed to get it working somehow. This script is working with a different method (bitcoin-cli sendmany) and I tried it and it did the correct math andd sent the correct amount of BTC into 2 adddresses.

You can see the script here. But I need to change the sendmany method because that will only work in a specific situation which isn't what I need. So I need to use "listunspent" and use the values returned by this method in the math needed.

I'll check when I get it working. I couldn't dod anything yesterday because I had to fix another issue. My node decided to corrupt blocks so I had to fix that. No node, no script testing. :)

I'll try to work on the script today!
Last edited by PsySc0rpi0n on 2020-06-04 17:40, edited 1 time in total.
User avatar
Posts: 247
Joined: 2012-10-24 13:54
Location: Portugal

Re: command issued from within bash script not working

Postby Head_on_a_Stick » 2020-06-04 17:30

FWIW ksh93 does floating point arithmetic:
Code: Select all
$ float x=10 y=4
$ echo $((x/y))

It's also *much* faster than bash :)
Black Lives Matter

Debian buster-backports ISO image: for new hardware support
User avatar
Posts: 13289
Joined: 2014-06-01 17:46
Location: /dev/chair

Re: command issued from within bash script not working

Postby ruwolf » 2020-06-04 23:14

Standard commands bc (and dc) can do floating point arithmetic (by switch -l, with almost arbitrary precision)...
User avatar
Posts: 429
Joined: 2008-02-18 05:04
Location: Slovakia, Banovce nad Bebravou, Matice slovenskej 1260/4-7


Return to Programming

Who is online

Users browsing this forum: No registered users and 6 guests