I am trying to write a shell script that receives as an input a command with arguments and runs it.
I am hoping to use this in cron as follows:
0 11 * * * my_wrapper.sh "task_name" "command arg1 arg2 arg3 ..."
Note that, as I put it above, my_wrapper.sh receives two arguments:
task_nameas a stringcommand arg1 arg2 arg3
The goal is to have my_wrapper.sh:
- Run
command arg1 arg2 arg3 ...* - Record the output of the command in a log file with filename
task_name
I am hoping to write my_wrapper.sh using zsh.
My questions are:
- What is the proper way of passing and receiving parameters to
my_wrapper.sh - Will I be able to handle any type of
command arg1 arg2 arg3? (quotes, etc.)
Needless to say, the following doesn't work:
#!/usr/bin/zsh
task_name=$1
command_to_run=$2
Aucun commentaire:
Enregistrer un commentaire