rsync unknown option from bash script execution

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












I'm trying to simply sync a folder using rsync over my local network from my computer in front of me to the destination computer.



#!/bin/bash

echo "This script will sync from my Macbook Dropbox/scripts/ folder to ruth@10.0.0.9 @ Norms house"

OPTIONS="--recursive --ignore-existing --progress"
SRC_DIR="~/Dropbox/scripts/"
DST_DIR="ruth@10.0.0.9:~/scripts/"
rsync "$OPTIONS" "$SRC_DIR" "$DST_DIR"


To give myself write privileges



chmod +x nameofscript.sh


When I run it, it outputs:



rsync: --recursive --ignore-existing --progress: unknown option


How do I properly store these options and run it as a script?







share|improve this question


















  • 1




    Please don’t add your solution to your question; if you feel the accepted answer isn’t complete enough, you can suggest an edit to that, or add your own separate answer.
    – Stephen Kitt
    Mar 22 at 22:16














up vote
2
down vote

favorite
1












I'm trying to simply sync a folder using rsync over my local network from my computer in front of me to the destination computer.



#!/bin/bash

echo "This script will sync from my Macbook Dropbox/scripts/ folder to ruth@10.0.0.9 @ Norms house"

OPTIONS="--recursive --ignore-existing --progress"
SRC_DIR="~/Dropbox/scripts/"
DST_DIR="ruth@10.0.0.9:~/scripts/"
rsync "$OPTIONS" "$SRC_DIR" "$DST_DIR"


To give myself write privileges



chmod +x nameofscript.sh


When I run it, it outputs:



rsync: --recursive --ignore-existing --progress: unknown option


How do I properly store these options and run it as a script?







share|improve this question


















  • 1




    Please don’t add your solution to your question; if you feel the accepted answer isn’t complete enough, you can suggest an edit to that, or add your own separate answer.
    – Stephen Kitt
    Mar 22 at 22:16












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I'm trying to simply sync a folder using rsync over my local network from my computer in front of me to the destination computer.



#!/bin/bash

echo "This script will sync from my Macbook Dropbox/scripts/ folder to ruth@10.0.0.9 @ Norms house"

OPTIONS="--recursive --ignore-existing --progress"
SRC_DIR="~/Dropbox/scripts/"
DST_DIR="ruth@10.0.0.9:~/scripts/"
rsync "$OPTIONS" "$SRC_DIR" "$DST_DIR"


To give myself write privileges



chmod +x nameofscript.sh


When I run it, it outputs:



rsync: --recursive --ignore-existing --progress: unknown option


How do I properly store these options and run it as a script?







share|improve this question














I'm trying to simply sync a folder using rsync over my local network from my computer in front of me to the destination computer.



#!/bin/bash

echo "This script will sync from my Macbook Dropbox/scripts/ folder to ruth@10.0.0.9 @ Norms house"

OPTIONS="--recursive --ignore-existing --progress"
SRC_DIR="~/Dropbox/scripts/"
DST_DIR="ruth@10.0.0.9:~/scripts/"
rsync "$OPTIONS" "$SRC_DIR" "$DST_DIR"


To give myself write privileges



chmod +x nameofscript.sh


When I run it, it outputs:



rsync: --recursive --ignore-existing --progress: unknown option


How do I properly store these options and run it as a script?









share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 22:14









Stephen Kitt

141k22307367




141k22307367










asked Mar 22 at 21:15









Kaiya

134




134







  • 1




    Please don’t add your solution to your question; if you feel the accepted answer isn’t complete enough, you can suggest an edit to that, or add your own separate answer.
    – Stephen Kitt
    Mar 22 at 22:16












  • 1




    Please don’t add your solution to your question; if you feel the accepted answer isn’t complete enough, you can suggest an edit to that, or add your own separate answer.
    – Stephen Kitt
    Mar 22 at 22:16







1




1




Please don’t add your solution to your question; if you feel the accepted answer isn’t complete enough, you can suggest an edit to that, or add your own separate answer.
– Stephen Kitt
Mar 22 at 22:16




Please don’t add your solution to your question; if you feel the accepted answer isn’t complete enough, you can suggest an edit to that, or add your own separate answer.
– Stephen Kitt
Mar 22 at 22:16










1 Answer
1






active

oldest

votes

















up vote
3
down vote



accepted










By quoting "$OPTIONS", the shell is passing it to rsync as a single string, so rsync is trying to find a single option named "--recursive --ignore-existing --progress", which obviously doesn't exist, since these are three separate options.



This should fix it for you:



rsync $OPTIONS "$SRC_DIR" "$DST_DIR"



A better option might be to use a bash array to store your options.



OPTIONS=(
--recursive
--ignore-existing
--progress
)
# ...
rsync "$OPTIONS[@]" "$SRC_DIR" "$DST_DIR"


The advantage of using an array is that then you are able to introduce items that include spaces, if any are necessary.






share|improve this answer




















  • The bash array works great to store the options, I've edited my original with the correct script. Thank you.
    – Kaiya
    Mar 22 at 21:55










  • Awesome @Kaiya, I'm glad this worked for you!
    – Filipe Brandenburger
    Mar 22 at 22:06










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432936%2frsync-unknown-option-from-bash-script-execution%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote



accepted










By quoting "$OPTIONS", the shell is passing it to rsync as a single string, so rsync is trying to find a single option named "--recursive --ignore-existing --progress", which obviously doesn't exist, since these are three separate options.



This should fix it for you:



rsync $OPTIONS "$SRC_DIR" "$DST_DIR"



A better option might be to use a bash array to store your options.



OPTIONS=(
--recursive
--ignore-existing
--progress
)
# ...
rsync "$OPTIONS[@]" "$SRC_DIR" "$DST_DIR"


The advantage of using an array is that then you are able to introduce items that include spaces, if any are necessary.






share|improve this answer




















  • The bash array works great to store the options, I've edited my original with the correct script. Thank you.
    – Kaiya
    Mar 22 at 21:55










  • Awesome @Kaiya, I'm glad this worked for you!
    – Filipe Brandenburger
    Mar 22 at 22:06














up vote
3
down vote



accepted










By quoting "$OPTIONS", the shell is passing it to rsync as a single string, so rsync is trying to find a single option named "--recursive --ignore-existing --progress", which obviously doesn't exist, since these are three separate options.



This should fix it for you:



rsync $OPTIONS "$SRC_DIR" "$DST_DIR"



A better option might be to use a bash array to store your options.



OPTIONS=(
--recursive
--ignore-existing
--progress
)
# ...
rsync "$OPTIONS[@]" "$SRC_DIR" "$DST_DIR"


The advantage of using an array is that then you are able to introduce items that include spaces, if any are necessary.






share|improve this answer




















  • The bash array works great to store the options, I've edited my original with the correct script. Thank you.
    – Kaiya
    Mar 22 at 21:55










  • Awesome @Kaiya, I'm glad this worked for you!
    – Filipe Brandenburger
    Mar 22 at 22:06












up vote
3
down vote



accepted







up vote
3
down vote



accepted






By quoting "$OPTIONS", the shell is passing it to rsync as a single string, so rsync is trying to find a single option named "--recursive --ignore-existing --progress", which obviously doesn't exist, since these are three separate options.



This should fix it for you:



rsync $OPTIONS "$SRC_DIR" "$DST_DIR"



A better option might be to use a bash array to store your options.



OPTIONS=(
--recursive
--ignore-existing
--progress
)
# ...
rsync "$OPTIONS[@]" "$SRC_DIR" "$DST_DIR"


The advantage of using an array is that then you are able to introduce items that include spaces, if any are necessary.






share|improve this answer












By quoting "$OPTIONS", the shell is passing it to rsync as a single string, so rsync is trying to find a single option named "--recursive --ignore-existing --progress", which obviously doesn't exist, since these are three separate options.



This should fix it for you:



rsync $OPTIONS "$SRC_DIR" "$DST_DIR"



A better option might be to use a bash array to store your options.



OPTIONS=(
--recursive
--ignore-existing
--progress
)
# ...
rsync "$OPTIONS[@]" "$SRC_DIR" "$DST_DIR"


The advantage of using an array is that then you are able to introduce items that include spaces, if any are necessary.







share|improve this answer












share|improve this answer



share|improve this answer










answered Mar 22 at 21:18









Filipe Brandenburger

3,461621




3,461621











  • The bash array works great to store the options, I've edited my original with the correct script. Thank you.
    – Kaiya
    Mar 22 at 21:55










  • Awesome @Kaiya, I'm glad this worked for you!
    – Filipe Brandenburger
    Mar 22 at 22:06
















  • The bash array works great to store the options, I've edited my original with the correct script. Thank you.
    – Kaiya
    Mar 22 at 21:55










  • Awesome @Kaiya, I'm glad this worked for you!
    – Filipe Brandenburger
    Mar 22 at 22:06















The bash array works great to store the options, I've edited my original with the correct script. Thank you.
– Kaiya
Mar 22 at 21:55




The bash array works great to store the options, I've edited my original with the correct script. Thank you.
– Kaiya
Mar 22 at 21:55












Awesome @Kaiya, I'm glad this worked for you!
– Filipe Brandenburger
Mar 22 at 22:06




Awesome @Kaiya, I'm glad this worked for you!
– Filipe Brandenburger
Mar 22 at 22:06












 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432936%2frsync-unknown-option-from-bash-script-execution%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?