Commit 4eb4271a authored by Afaq Tariq's avatar Afaq Tariq
Browse files

Merge pull request #370 from alozovskoy/fix365

Add quotes escaping for cron scripts
parents 0ba4f560 5afe4fd4
......@@ -10,9 +10,9 @@ result=$($grepCmd -m$numberOfLines CRON $cronLog \
| awk '{ s = ""; for (i = 6; i <= NF; i++) s = s $i " "; \
print "{\"time\" : \"" $1" "$2" "$3 "\"," \
"\"user\" : \"" $6 "\"," \
"\"message\" : \"" $5" "s "\"" \
"\"message\" : \"" $5" "gensub("\"", "\\\\\"", "g", s) "\"" \
"},"
}'
)
echo [${result%?}]
\ No newline at end of file
echo [${result%?}]
......@@ -9,6 +9,7 @@ sedCmd=`which sed`
egrepCmd=`which egrep`
echoCmd=`which echo`
crontabCmd=`which crontab`
trCmd=`which tr`
# System-wide crontab file and cron job directory. Change these for your system.
CRONTAB='/etc/crontab'
......@@ -80,9 +81,11 @@ $catCmd "${temp}" \
" \"month\": \"" $4 "\", " \
" \"weekday\": \"" $5 "\", " \
" \"user\": \"" $6 "\", " \
" \"command\": \"" $7$8$9$10 "\" " \
" \"command\": \""} \
{for(i=7;i<=NF;++i) printf("%s ", gensub("\"", "\\\\\"", "g", $i) ) } \
{print "\" " \
"}," } \
END {print "]"}' \
| $sedCmd 'N;$s/,\n/\n/;P;D'
| $sedCmd 'N;$s/,\n//;P;D' | $trCmd -s '\n' ' '
rm --force "${temp}"
\ No newline at end of file
rm --force "${temp}"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment