Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am trying to find a way to upload batch of files from one server to another by cron few times a day and wput seems like best and easiest option to use.

It works so far fine, but problem is that wput always recreating directory tree on destination. So here is command i use.

wput -u /var/www/clients/client1/web/parser/*.json ftp://username:password@remoteserver/web/

So this is supposed to upload all the files inside directory /parser/ and files that have .json extension.

This works very nice, except:

When it upload the files to remote server it uploads whole directory tree and instead of having a list of files inside /web/ folder on remote server the files are uploaded with all directories from source server

Instead having this:

/web/file1.json
/web/file2.json
/web/file3.json
/web/file4.json

I have this

/web/var/www/clients/client1/web/parser/file1.json
/web/var/www/clients/client1/web/parser/file2.json
/web/var/www/clients/client1/web/parser/file3.json
/web/var/www/clients/client1/web/parser/file4.json

How can i prevent wput to upload whole directory tree on remoteserver?

2

1 Answer

The problem is that wput is always recreating the directory tree on the destination

You need to use the −−basename=path option:

This option causes Wput to snip path from all input−files when they are connected to the URL. wput /usr/share/doc.tgz ftp://host/ would create ftp://host//usr/share/doc.tgz, whereas specifying /usr/share/ as basename will result in ftp://host/doc.tgz being created.

Source wput

Try the following command:

wput --basename=/var/www/clients/client1/web/parser -u /var/www/clients/client1/web/parser/*.json ftp://username:password@remoteserver/web/
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy