I've been trying to automate git pulls with a Bash script. To make sure I don't miss the execution results of the script, and yo log these results somewhere for possible reviews if things go wrong, I've added this line to my script :
# Does git pull `notify-send "Git pull log message" |tee -a "$mylogfile" # Other stuff
The rest of the script works fine, it does what's expected e.g. perform a git pull automatically. The notification given to
notify-send also displays fine on my computer, and I can access it from the notification list.
My problem is what I pipe the notification into (
|tee -a $mylogfile). It simply doesn't redirect the notification message to the file
$mylogfile. I've also tried :
notify-send "Git pull log message" |tee "$mylogfile" notify-send "Git pull log message" > "$mylogfile" notify-send "Git pull log message" >> "$mylogfile"
which don't appear to write anything either. I also ran these commands from both a script and the terminal, same behaviour. The manual page for
notify-send is also very short, and doesn't mention anything about how to use the command with file I/O. I've also not found related questions on Stack Exchange, [this one] being the closest, but I'm trying to get notify-send output to a file, not give it a file as input.I guess nothing is redirected because there's no output displayed in the terminal, which means nothing is written to stdout.
I guess I could settle for something like
msg="Git pull log message" notify-send "$msg" && echo "$msg" > "$mylogfile"
which would work by splitting the command in 2 lines and using a variable, but I'd like to keep it to one line and no explicit variable so that only that line in the script pertains to the notification and its logging, and nothing else.
I'm sure I must have missed something obvious. Could you please help me with that? : https://askubuntu.com/questions/216326/can-i-redirect-file-as-input-to-notify-send