Answer the question
In order to leave comments, you need to log in
Bash does not process the script correctly. What's wrong?
In the next question, when run, the result is 0, although there is not zero, how to make it pass the correct values from exim -bpc?
#!/bin/bash
exim -bpc
result=$?
if [ $result -gt 50 ]; then
echo "Before sending:" >f.txt
echo $result >>f.txt
exim -qff
exiqgrep -o 86400 -i | xargs exim -Mrm
echo "After force sending:" >>f.txt
exim -bpc >>f.txt
mail -s "Forced sending" [email protected] <./f.txt
fi
Answer the question
In order to leave comments, you need to log in
In the variable $? is the return code of the previous command. Usually zero means that it completed successfully.
You want to get the data that the command printed to stdout, for this bash (and *sh in general) has the $( command ) construct .
In your case the fix is trivial:
result=$(exim -bpc)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question