raphaelcohn / bish-bosh

MQTT shell script client, for bash, dash, BusyBox ash and others. Gives you MQTT on anything Unix like, from embedded routers to AIX servers with almost no dependenices.
https://github.com/raphaelcohn/bish-bosh
Other
216 stars 37 forks source link

bishbosh_publishFile fails on Busybox ash (openwrt) #12

Open fundef1 opened 6 years ago

fundef1 commented 6 years ago

$2 doesn't get set which causes an unkown operand error and then: ./bish-bosh: ./lib/shellfire/core/init.functions: line 1: 2: parameter not set when calling dd in

bishbosh_connection_write_file()
     {
              dd if="$1" bs=$2 count=1
     }

root cause is bishbosh_filesize_ls() returning empty.

bishbosh_filesize_ls()
{
    # dateBitsAndFileName are not portable
    # permissions may have a '@' on the end if it is Mac OS X ls    
    local permissions links uid gid size dateBitsAndFileName

    IFS=' ' read -r <<-EOF
        $(ls -L -l -n "$1")
    EOF
}

workaround: use stat --filesize-algorithm GNUAndBusyBoxStat (or don't use dd )