Use wput to send files through the network

You don’t have to open up your FTP client (whatever it is) to connect to the server when all you want is upload a single file or a bunch of directories.
Using wput is simple and very efficient when you want to do send files through FTP connections.
Ubuntu or Debian users can install wput using the apt-get command:

sudo apt-get install wput

Fedora users can do it with yum:

sudo yum install wput

And there’s a Windows version on sourceforge.
network connections

wput command syntax

To send all files from a local directory to the remote FTP server the syntax would be something like this:

wput *.* ftp://username:password@hostname/recipient-folder/

In the following examples I’ll assume my username is slinkydog and my password is dachshund. My server address would be toystoryfun.com (I didn’t check if it exists and it doesn’t matter. Use your own server names here). The recipient folder in the server will be called characters/.
This is the first example on how to send a single file through your FTP connection:

wput filename.txt ftp://slinkydog:dachshund@toystoryfun.com/characters/

How to deal with wput verbosity

You can reduce the verbosity, using --less-verbose option:

wput --less-verbose filename.txt ftp://slinkydog:dachshund@toystoryfun.com/characters/

You can use the option --verbose to increase the command output even more or the option quit to simply suppress verbosity.
I usually prefer to send wput to work in the background which sets my terminal free to run other stuffs. This is how to do it:

wput --background *.* ftp://slinkydog:dachshund@toystoryfun.com/characters/

If you wantto know what’s happening (or happened) during the transference just read the file ./wputlog:

less ./wputlog

How to limit the bandwidth usage while sending files with wput

The option --limit-rate can be used to limit the average use of your network bandwidth. In the following example I’ll limit it to 500 K:

wput --limit-rate=500K --less-verbose about.php index.php styles.css ftp://slinkydog:dachshund@toystoryfun.com/characters/

In the example above I limited the average rate of bandwidth usage to 500 K, decreased verbosity level and told wput to transfer the files:

  • about.php
  • index.php
  • styles.css

You can use wildcards like *.php if you want.

How to resume incomplete uploads with wput

Wput resumes incomplete transfers by default. So you don’t need to do anything special here.
Though you can force it to do it all again by telling the program to reupload:

wput --reupload --less-verbose --limit-rate=1M *.php *.css *.html ftp://slinkydog:dachshund@toystoryfun.com/characters/

Take a look at the man page of the command to see more options:

man wput

… and have fun!

Publicado por

Elias Praciano

Autor de tecnologia (livre, de preferência), desenvolvedor web e geek, nos mais diversos assuntos. Entusiasta de software livre e hacker de LEGO, acredito em repassar meu conhecimento e ajudar as pessoas sempre que for possível.

Deixe uma resposta

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *