Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I created a script to upload a file to my ftp server once week. The problem is that the file name changes every day. is there a way I could setup this script to copy *.123 instead of specifying a file name?
script: echo off
echo Backing up your data offsite, please wait...
wput -v *.123 ftp://ftpuserassword@ftpserver/ftpfolder/
I tried this script but it did not find the file above *.123.
Before I go fully answering this, what type of script is this? I ask because I see the "echo off" above, and it reminds me of windows.... Also, what shell are you using? Normally in linux, this would work. A quick solution off the top of my head, in linux, would be to list all files with that extension, and pipe to a new file, then use the -i argument with wput, a such:
ls *.123 > file1
wput -i file1 ftp://user:password@server/folder/
Well then that explains it. Why would you post a windows type question in a linux forum? Reporting this thread to be moved... Sorry to come off as a dick, but seriously, these are linux forums...... Hope you understand! And by the way.... I don't use windows at all, let-alone script batch files anymore. Sorry I can't help you, but I can not emulate what you are trying to do, since I don't have windows installed on any of my computers.
The reason why I posted it is because I am using 'wput' which I believe is an Open Source program that comes for Linux and W$ndows. Also, the FTP where the file is being uploaded to is a Ubuntu LTS server running vsftpd server. If I go to a W$ndows forum, I am sure they will direct me to a 'paid FTP program' to be able to accomplish what I want to do. I wish I could get rid of W$ndows but there are many applications that need to be run under W$ndows.
In that case, the easiest way to take advantage of solns above that use Linux shell is to install Cygwin on your MS system.
This gives you a *nix style interface (in addition to whatever is there already), so that you can use most shell cmds and other *nix tools.
there is a way if using command line FTP client - LFTP (install Cygwin and when installing packages check LFTP)
and then you can use command "mput":
Usage: mput [OPTS] <files>
Upload files with wildcard expansion
-c continue, reput
-d create directories the same as in file names and put the
files into them instead of current directory
-E delete local files after successful transfer (dangerous)
-a use ascii mode (binary is the default)
-O <base> specifies base directory or URL where files should be placed
All in one line would be:
lftp -c "open $HOST && user $USER $PASSWD && cd FOLDER_NAME_FOR_STORING/backups/ && mput $FILE"
- $HOST is your ftp address
- $USER $PASSWD - self explanatory
- $FILE - filename / names pattern
lftp -c "open mysiteftp.net && user ftpuserftppassword && cd /home/ftpuser/backups && mput *.123"