Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

command issued from within bash script not working

Programming languages, Coding, Executables, Package Creation, and Scripting.
Message
Author
User avatar
PsySc0rpi0n
Posts: 321
Joined: 2012-10-24 13:54
Location: Bitcoin World
Has thanked: 8 times
Been thanked: 1 time

Re: command issued from within bash script not working

#31 Post by PsySc0rpi0n »

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
Head_on_a_Stick
Posts: 14114
Joined: 2014-06-01 17:46
Location: London, England
Has thanked: 81 times
Been thanked: 132 times

Re: command issued from within bash script not working

#32 Post by Head_on_a_Stick »

FWIW ksh93 does floating point arithmetic:

Code: Select all

$ float x=10 y=4
$ echo $((x/y)) 
2.5
$
https://packages.debian.org/buster/ksh

It's also *much* faster than bash :)
deadbang

User avatar
ruwolf
Posts: 618
Joined: 2008-02-18 05:04
Location: Banovce nad Bebravou
Has thanked: 34 times
Been thanked: 26 times

Re: command issued from within bash script not working

#33 Post by ruwolf »

Standard commands bc (and dc) can do floating point arithmetic (by switch -l, with almost arbitrary precision)...

Post Reply