How to pass options to rclone with xargs (Linux)?

I’ve got this in a bash script:

rclone_cmd_type="$type"
rclone_cmd_options="$RC_OPTS_CONSTANT $options_variable"
rclone_cmd_source="$path_source"
rclone_cmd_dest="$path_destination_full"
echo "$rclone_cmd_type" "$rclone_cmd_options" "$rclone_cmd_source" "$rclone_cmd_dest" | xargs rclone

rclone isn’t liking it, seemingly because all the --options are being passed as a single string. How to pass them - given that their number can vary - as a single string? Should I use exec? I don’t know the syntax for that.

I think this will work better

rclone $rclone_cmd_type $rclone_cmd_options $rclone_cmd_source $rclone_cmd_dest

That assumes that you’ve put “” round anything that has spaces in… Maybe this would work better

rclone $rclone_cmd_type $rclone_cmd_options "$rclone_cmd_source" "$rclone_cmd_dest"

Thanks. I tried your second option, and rclone seems not to run at all. Weird. The same happens if I do:

echo \
"$rclone_cmd_type"\
"$rclone_cmd_options"\
"$rclone_cmd_source"\
"$rclone_cmd_dest"\
| xargs rclone

having generated rclone_cmd_options from an array. Stranger yet, perhaps: when (and only when) both (i) I generate rclone_cmd_options from an array, (ii) that array is a simple array, rather than one generated by combining two arrays, rclone works. (I combine two arrays because I’ve one set of constant options - options I use for every job - and another set of variable options. I use one array for each.)

EDIT: It might help to add the following. The inset code above does work when I cut out the line containing rclone_cmd_options. The options, when generated in any of the methods I’ve used, looks like this:

--fast-list --progress --stats-one-line --skip-links --checkers=9 --drive-chunk-size=512K --log-level=NOTICE --retries=2 --timeout=4m --tpslimit 299 --tpslimit-burst 400 --drive-use-trash=false --delete-during --filter-from /home/<myUserName>/Downloads/Backup_setup/rclone/lists/conf_filter-from --transfers=7

OK, I’ve got things working - using these methods: use arrays for the – options, but unpack the arrays before passing to rclone; call rclone without any de-globbing. What was stopping my script from working was a typo messing up the specification of the ‘remote’ at issue. Thanks for your help, Craig.

1 Like