1
votes

I've got a script like this:

dyski=$(df -h)

while read wiersz; do

i=0;
for token in $wiersz
do

    case $i in
        0)
            tresc="$tresc\nSystem plików: $token";
        ;;

        1)
            tresc="$tresc\nRozmiar całkowity: $token";
        ;;

        2)
            tresc="$tresc\nUżyte miejsce : $token";
        ;;

        3)
            tresc="$tresc\nDostępne miejsce: $token";
        ;;

        4)
            tresc="$tresc\nProcentowe użycie: $token";
        ;;
    esac

    i=$((i+1))
done

tresc="$tresc\n"

done < <(echo "$dyski")

When I run it on my Mandriva, it works fine. But when I move it to the SLES11, it gives an error:

./diskcheck.sh: line 42: syntax error near unexpected token <' ./diskcheck.sh: line 42:done < <(echo "$dyski")'

What's wrong with it? Thanks in advance for help.

1
Looks like you've got two "<" characters, buddy. - Samuel Bierwagen

1 Answers

2
votes

I suspect you've made the mistake of assuming that /bin/sh is bash everywhere. A number of Linux distributions use simpler shells (often dash, sometimes ksh) as /bin/sh; if you want to use bash-specific extensions such as <(pipeline) syntax, you should explicitly use bash as the shell.