"binary operator expected" message

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jmvidalvia
    New Member
    • Oct 2007
    • 2

    "binary operator expected" message

    Hi!
    My second post, very similar to the first one.
    I just mounted a debian server and start to run some few scripts. They "seem" to run, but sometimes (5% of times) I am getting this error message:

    Code:
    /home/jmd/sh/muestras.sh: line 2: [: R0220444: binary operator expected
    Note that R0220444 is one of the files in /home/as400/muestras folder.

    This is /home/jmd/sh/muestras.sh:
    Code:
    #!/bin/bash
    if [ -z $(ls /home/as400/muestras) ]
    then
            echo "" > /dev/null
    else
            /home/jmd/sh/muestrasR.sh
    fi

    And this is /home/jmd/sh/muestrasR.sh
    Code:
    #!/bin/bash
    cd /home/as400/muestras
    touch prueba
    
    for i in `ls *`; do
    fichero=`echo $i | cut -d. -f1`
    txt2html -pb 0 --infile $fichero --outfile $fichero.html
    done
    
    for i in `ls *.html`; do
    fichero=`echo $i | cut -d. -f1`
    htmldoc --quiet --left 4mm --fontsize 12 --textfont helvetica --webpage -f $fichero.pdf $fichero.html
    done
    
    chown nobody:desa *
    chmod 660 *
    
    mv *.pdf /home/datos/compras/muestras/
    rm *
    rm /home/datos/compras/muestras/prueba.*
    That messages just appear sometimes.
    Youy might know that files are send to /home/as400/cartas from a IBM iseries using ftp.
    Thank you very much for your help!
  • arne
    Recognized Expert Contributor
    • Oct 2006
    • 315

    #2
    As far as I understand your code, you check if there are files in one folder and if so, invoke the other script which manipulates them.

    Did you try
    Code:
    if [ -z "$(ls /home/as400/muestras)" ]
    ? (Note the additional quotes.)

    HTH,
    arne

    Comment

    Working...