1

I'm using ncftpput to upload images to a ftp server. An example of the script is

#                         destination.       origin
ncftpput -R ftp_server icon_d2/cape_cin ./cape_cin_*.png
ncftpput -R ftp_server icon_d2/t_v_pres ./t_v_pres_*.png
ncftpput -R ftp_server icon_d2/it/cape_cin ./it/cape_cin_*.png
ncftpput -R ftp_server icon_d2/it/t_v_pres ./it/t_v_pres_*.png

I'm trying to parallelize this with GNU parallel but I'm struggling to pass the arguments to ncftpput. I know what I'm doing wrong but somehow can not find the solution.

If I construct the array of what I need to upload

images_output=("cape_cin" "t_v_pres")

# suffix for naming
projections_output=("" "it/")
# remote folder on server
projections_output_folder=("icon_d2" "icon_d2/it")

# Create a list of all the images to upload 
upload_elements=()
for i in "${!projections_output[@]}"; do
    for j in "${images_output[@]}"; do
        upload_elements+=("${projections_output_folder[$i]}/${j} ./${projections_output[$i]}${j}_*.png")
    done
done

Then I can do the upload in serial like this

for k in "${upload_elements[@]}"; do
   ncftpput -R ftp_server ${k}
done

When using parallel I'm using colsep to separate the arguments

parallel -j 5 --colsep ' ' ncftpput -R ftp_server ::: "${upload_elements[@]}"

but ncftpput gives an error that tells me it is not understanding the structure of the passed argument. What am I doing wrong?

Droid
  • 441
  • 1
  • 3
  • 18

1 Answers1

0

Try:

parallel -j 5 --colsep ' ' eval ncftpput -R ftp_server ::: "${upload_elements[@]}"

This should do exactly the same:

for k in "${upload_elements[@]}"; do
   echo ncftpput -R ftp_server ${k}
done | parallel -j 5
Ole Tange
  • 31,768
  • 5
  • 86
  • 104