0

I have a script for backing up my data. The last line is:

echo "$FTPConnectstring
$FTPCommands
bye" | ftp -ivn

It works great, but I wish I could 'trickle' this (i.e. limit upload bandwidth usage). I tried many command lines like these:

echo "$FTPConnectstring
$FTPCommands
bye" | ftp -ivn | trickle -s -u 4096

but ftp transfer seems to execute with no BW usage limit I also tried something like this

FinalCommand=$(echo -e "$FTPConnectstring\n$FTPCommands\nbye")
trickle -s -u 4096 ftp -ivn ${FinalCommand}

but this one doesn't connect ftp correctly...

Any help appreciated !!

tripleee
  • 175,061
  • 34
  • 275
  • 318
felix
  • 33
  • 6
  • The correct syntax would be something like `echo -e "$FTPConnectstring\n$FTPCommands\nbye" | trickle -s -u 4096 ftp -ivn` but if `ftp` is statically linked, this probably doesn't do what you had hoped. – tripleee Dec 11 '18 at 10:06
  • thx for your comment. Should I understand that what I'm trying to achieve is not possible ? – felix Dec 11 '18 at 10:11
  • If it doesn't work, try using a different FTP client like `ncftp` which should also be easier to script. Maybe experiment with omitting the `-s` option if you have the daemon running. – tripleee Dec 11 '18 at 10:13
  • FYI : ldd $(which ftp) | grep libc.so returns libc.so.6 => /lib64/libc.so.6... as expected for working with trickle. I tried your suggestion and the result is the same, no BW limit applied... – felix Dec 11 '18 at 10:16

1 Answers1

0

In your first attempt, you only trickle the standard output from ftp (depending on the implementation, probably just the progress messages, if even that). In your second attempt, you have a syntax error; the argument to ftp should be a host name, not a command sequence. Try this instead:

echo -e "$FTPConnectstring\n$FTPCommands\nbye" |
trickle -s -u 4096 ftp -ivn

If the ftp binary is statically linked, trickle can't override its socket-handling internals; but in that case, you can probably switch to a different FTP client such as ncftp which should also behave better with scripting.

tripleee
  • 175,061
  • 34
  • 275
  • 318