I have a simple bash script below
#!/bin/bash
sratio=`/root/trap -t -a | awk -F '|' '{print $6}' | sed -e 's/[\t ]//g;/^$/d' | sed '1,2d' | awk '{n += $1}; END{print n}'`
tdisks=`/root/trap -t -a | grep "/dev/sd" | wc -l`
result=$(echo "scale=4; $sratio / $tdisks" | bc)
echo "$result" > /root/tratio.txt
The above script executes fine, when it is run in the terminal, however whenever I put in the cron it fails. Please note trap is a binary file and the command outputs are stored as variables i.e. sratio and tdisks. The sample outputs of sratio (floating) and tdisks (integer) are "23.567" and "80".
* * * * * /tmp/ratio.sh > /tmp/log.txt 2>&1
The error I could see is below in the logs. Please let me know how can i solve this issue.
standard_in 1 syntax error