I have just lost my mind. I code in Windows, now i have to make one tiny plug-in in Linux, to get communicated with my main code. I make code in bash, and on Windows, everything will be ok, but here, on Debian... I have spend 2 days to figure out what is going on, and tried almost everything.
It is my code :
#!/bin/bash
search1=`cat /home/qlik/skrypty/windows/kody.txt | grep -E '[0-2]'`
case $search1 in
[|1|])
echo "Error, need restart"
exit 2
;;
case $search1 in
[|2|])
echo "Warning with server process, waiting"
exit 1
;;
*)
echo "OK"
exit 0
;;
esac
I have also tried that way
#!/bin/bash
plik1='/home/qlik/skrypty/windows/kody.txt'
szukaj1=$( grep 1 $plik )
szukaj2=$( grep 2 $plik )
if [ $($szukaj1) -eq "1" ] ; then
echo "Error, need restart"
exit 2
elif [ $($szukaj2) -eq "2" ] ; then
echo "Server process warning, waiting"
exit 1
else
echo "OK"
exit 0
fi
and all kinds of different ways. All the time I've got an errors :
integer expression expected
or
binary operator expected
or
[: -eq: unary operator expected
I have read about that, i think the problem is with symbols $(...)/[...]/.../'...'/[[...]]/$($...)/"..." and I really, really don't know what to do with my code, i tried almost all configurations.
The code is simple -
- it read file.txt
in file.txt there are 4 numbers [for example : 0 0 2 0 ]
if all are 0, then is ok,
if one of them is 1, then is error
if one of them is 2, then is information that process failed.
- when 1 or 2 are met, the exit code should be the same as error in txt
I just need to recognize what number is in file.txt and show different information and exit code.
Could You please help me?
echo $search1?cat /home/qlik/skrypty/windows/kody.txt | grep -E '[0-2]'echo $search1 the result is, like my txt file : 0 0 1 0$search1' ./qlik_procesresponse.sh: line 8:case $search1 in' * and then on that console when I wrote *echo $search1, the result is blank space, like echo of anything = blank enter