Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-19-2019, 09:34 AM   #16
Registered: Jun 2003
Location: Phoenix, AZ
Posts: 91

Original Poster
Rep: Reputation: 15

I've tried all of these, but still doesn't work. I either get errors or still returning 0. Here is exactly what I want to do.

I wrote a small script to send a message to my phone. Right now I still have to use 2 commands for success or failure

rsync -avh /home /mnt/home && "rsync successful" "completed" --options || "rsync failed" "not completed" --options

Wanted to try to make this easier and detect what happened and change message based on that.

rsync -avh /home /mnt/home ; "rsync "message" --options

I have if statements do detect if previous command was successful then it would add messages like [SUCCESS] and [FAILED] to the title for me. But I keep getting a return of 0 since I'm not running rsync from within the script itself. Of course I could add this rsync command to the script, but then it's not as flexible if I want to use for other commands.

In a perfect world I would want it to work like 'grep' and |pipe| the error output to it of previous command and it can do what it does.
Old 03-19-2019, 10:19 AM   #17
LQ Newbie
Registered: Jan 2012
Posts: 12

Rep: Reputation: Disabled
You should be able to preserve return code in the child script without hurting other users, or make your own child script, or call rsync in your script, or find another way to verify success.
Old 03-20-2019, 04:36 AM   #18
Registered: Nov 2007
Location: Northeastern USA
Distribution: kubuntu
Posts: 179

Rep: Reputation: 95
In your main script:

rsync rsync-parameters
pushover "$rc"
and, inside pushover:

if (( $1 ))
  echo "rsync failed with error code [$1]"
  echo "rsync completed successfully"


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Get first day of last month and last day of last month in bash xowl Linux - Software 18 02-09-2017 09:49 AM
How can I pipe output of a command into arguments of a script HGeneAnthony Linux - General 3 12-26-2007 06:24 AM
Read the output from a pipe with bash ? fluppi Linux - Software 3 01-13-2004 12:59 PM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration