LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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!

Notices

Reply
 
Search this Thread
Old 02-24-2012, 02:23 PM   #1
ceantuco
Member
 
Registered: Mar 2008
Location: New Jersey
Distribution: CentOS, Debian, Mint, Backtrack, OpenSuse
Posts: 560

Rep: Reputation: 36
Question Wput script


Hi,

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...
cd \
cd folder
cd backup
wput -v *.123 ftp://ftpuserassword@ftpserver/ftpfolder/

I tried this script but it did not find the file above *.123.

Thank you!

Last edited by ceantuco; 02-24-2012 at 02:24 PM.
 
Old 02-24-2012, 04:09 PM   #2
ricstirato
Member
 
Registered: Jan 2004
Location: Gießen, Germany
Distribution: Xubuntu 12.04, Mythbuntu, Ubuntu Server 12.04
Posts: 174

Rep: Reputation: 24
Why not replace the last line with the following:

for FILE in *.123; do
wput -v $FILE ftp://ftpuserassword@ftpserver/ftpfolder/
done
 
Old 02-24-2012, 04:13 PM   #3
corp769
Guru
 
Registered: Apr 2005
Posts: 5,814

Rep: Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001
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:
Code:
cd /folder/backup
ls *.123 > file1
wput -i file1 ftp://user:password@server/folder/
 
Old 02-24-2012, 10:30 PM   #4
ceantuco
Member
 
Registered: Mar 2008
Location: New Jersey
Distribution: CentOS, Debian, Mint, Backtrack, OpenSuse
Posts: 560

Original Poster
Rep: Reputation: 36
ricstirato, I will try that. Thanks for your response.
corp769: Yes, it is a W$ndows machine. It is a DOS batch file.
Thanks
 
Old 02-25-2012, 03:43 AM   #5
corp769
Guru
 
Registered: Apr 2005
Posts: 5,814

Rep: Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001Reputation: 1001
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.

Cheers,

Josh
 
Old 02-27-2012, 03:46 PM   #6
ceantuco
Member
 
Registered: Mar 2008
Location: New Jersey
Distribution: CentOS, Debian, Mint, Backtrack, OpenSuse
Posts: 560

Original Poster
Rep: Reputation: 36
Josh,

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.
 
1 members found this post helpful.
Old 02-27-2012, 06:31 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,311

Rep: Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040Reputation: 2040
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.
 
1 members found this post helpful.
Old 03-12-2012, 09:28 AM   #8
ceantuco
Member
 
Registered: Mar 2008
Location: New Jersey
Distribution: CentOS, Debian, Mint, Backtrack, OpenSuse
Posts: 560

Original Poster
Rep: Reputation: 36
Thank you Chrism! I will try that. I appreciate your help. Cheers!
 
Old 03-12-2012, 10:52 AM   #9
lithos
Senior Member
 
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
Hi ceantuco

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":
Code:
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:
Code:
lftp -c "open $HOST && user $USER $PASSWD && cd FOLDER_NAME_FOR_STORING/backups/ && mput $FILE"
where:
- $HOST is your ftp address
- $USER $PASSWD - self explanatory
- $FILE - filename / names pattern

like:
lftp -c "open mysiteftp.net && user ftpuser ftppassword && cd /home/ftpuser/backups && mput *.123"

Last edited by lithos; 03-12-2012 at 11:04 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to return values to C from shell if wput is success ? jeethu Linux - Newbie 2 10-16-2009 08:04 AM
Is it possible to make such fast webcam, with wput? frenchn00b Programming 1 03-05-2009 03:45 AM
wput not uploading whiteghetto Linux - Software 0 08-22-2008 01:59 PM
wput and anonymous FTP whiteghetto Linux - Software 1 08-19-2008 03:43 PM
vsftpd and wput mnotgninnep Debian 8 03-07-2006 06:06 PM


All times are GMT -5. The time now is 06:23 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration