Thank you Berny. You helped me a lot :-) Wish you the best. Robert
> On 21 Dec 2016, at 08:40, Bernhard Voelker <[email protected]> wrote: > > On 12/20/2016 10:35 PM, aws backup wrote: >> Ok I started the screen command like this: >> >> *screen -dmS test /bin/bash -c "/path/to/fswatch.sh"* > > if the script is executable, then you can omit the "/bin/bash -c" here. > >> then the first script fswatch.sh: >> >> *#!/bin/bash >> fswatch -0 -Ie '.*\.*$' -i '.*\.mp4$' /path/to/folder \ >> | xargs -0 -n 1 /path/to/s3cmd.sh* >> >> then the second script s3cmd.sh: >> >> *#!/bin/bash >> filename="$(basename "$1")" >> terminal-notifier -message "s3cmd Upload '$filename' started" >> >> s3cmd put "$1" s3://bucket/ \ >> | tee /path/to/logfile.txt \ >> | tee >(mail -s 'Upload $filename' [email protected] >> <mailto:[email protected]>) \ >> && /usr/local/bin/terminal-notifier -message "s3cmd Upload of >> '$filename' done"* >> * >> * >> The second tee command is to get the output also in the screen terminal to >> see what's going on when I attach the screen. > > tee can do that, maybe you look here to find out how: > http://www.gnu.org/software/coreutils/tee > >> Now what's happening. I change a filename. xargs transfers first the old >> file name (before renaming) to the script. >> Therefore I get the notifications upload started and upload done for the old >> filename and following error from s3cmd >> (also as email): >> >> *ERROR: Parameter problem: Nothing to upload.* >> *Null message body; hope that's ok* >> * >> * >> Which is correct because the old file is not existing anymore. >> >> Then xargs transfers the new file name (after renaming) to the script and >> everything works as expected. Just the >> variable "$filename" in the mail command doesn't work. The subject of the >> notification email is "Upload $filename". >> >> How can I avoid that the old file name is transferred to the script? > > I do not know fswatch, so you should have a look into its manual how > to suppress that. > >> Why does the mail command not understand $filename? > > This is because you have single quotes ('...') around the message text. > Therefore, the shell doe no variable expansion. > > $ v=world > $ echo 'hello $v' > hello $v > $ echo "hello $v" > hello world > > But all this is far beyond the initial xargs question. You're probably > much better off asking in some shell scripting forum than here on the > findutils project mailing list. > > Have a nice day, > Berny _______________________________________________ Findutils-patches mailing list [email protected] https://lists.gnu.org/mailman/listinfo/findutils-patches
