lundi 26 mars 2018

Bash Script Conditions

I'm building a bash script to send an email based off the last command. I seem to be having difficulties. Outside of a script the command works fine but when putting it in script it doesn't give the desired outcome.

Here is snippet of script:

grep -vFxf /path/to/first/file /path/to/second/file > /path/to/output/file.txt 
if [ -s file.txt ] || echo "file is empty";
then
          swaks -t "1@email.com" -f "norply@email.com" --header "Subject: sample" --body "Empty"
else
          swaks -t "1@email.com" -f "norply@email.com" --header "subject: sample" --body "Not Empty"
fi

I ran the commands outside of script and I can see that there is data but when I add the commands within script I get the empty output. Please advise . Thank you in advance .

Aucun commentaire:

Enregistrer un commentaire