I’m trying to create a scp command to copy over a variable number of files to another computer. I’d like for it to be a single scp call rather than one per file as it is much more efficient. I have something looking like this:
function CreateStagingCommand(ip_addr::AbstractString, operations::Vector{ProcessReplacement})
files = ""
for replacement in operations
# Add the file-path to the list of things to copy
files *= "$(replacement.replacement_location) "
end
command = `scp -i "~"/real/file/path/here/id_rsa $(files) root@$(ip_addr):$(staging_area)`
return command
end
Problem is, Julia sees the $(files) as a single parameter with spaces in it and (not so) helpfully puts quotes around. It’s possible to do something like:
function CreateStagingCommand(ip_addr::AbstractString, operations::Vector{ProcessReplacement})
files = ""
for replacement in operations
# Add the file-path to the list of things to copy
files *= "$(replacement.replacement_location) "
end
command = `scp -i "~"/real/file/path/here/id_rsa $(a)$(b)$(c)$(d)$(etc) root@$(ip_addr):$(staging_area)`
return command
end
but that means I have to be aware of the max number of files a user is going to copy ahead of time, and also makes the code much uglier to read and maintain.
Anyone have a good way to handle this?