Ubuntu 16.04
I am wanting to echo the original command to a log file. My log file should look something like this:
Mon 04/16/18 04-24-pm - Executing command: sudo /home/editini.sh "one" "two" "three" "four" "five" "six"
What would be the easiest way to accomplish this while satisfying spellcheck at the same time.
#!/bin/bash
hello="${1}"
my="$2"
friend="$3"
are="$4"
you="$5"
safe="$6"
timeStamp="$(date '+%a %D %m-%S-%P')"
rm -rf report*; touch report.txt;
{
echo "$timeStamp - Executing command: sudo /home/editini.sh \"$hello\" \"$my\" \"$friend\" \"$are\" \"$you\" \"$safe\""
echo ""
echo "$timeStamp" - Executing command: sudo /home/editini.sh "$*"
echo "";
echo "$timeStamp" - Executing command: sudo /home/editini.sh \""$*"\"
echo "";
} > report.txt
cat report.txt
I can't go with the first line because I would have to know the arguments ahead of time.
This is what console says when I run the above commands.
root@me /home/scripts/vent-commands # sh one.sh one two three four five six
Mon 04/16/18 04-05-pm - Executing command: sudo /home/editini.sh "one" "two" "three" "four" "five" "six"
Mon 04/16/18 04-05-pm - Executing command: sudo /home/editini.sh one two three four five six
Mon 04/16/18 04-05-pm - Executing command: sudo /home/editini.sh "one two three four five six"