![]() |
![]() |
![]() |
|||||
![]() |
![]() |
![]() |
![]() |
![]() |
|||
| Welcome
to Tech Support Forum home to more then 136,000 problems solved. Issues
have included: Spyware, Malware, Virus Issues, Windows, Microsoft,
Linux, Networking, Security, Hardware, and Gaming Getting your
problem solved is as easy as: 1. Registering for a free account 2. Asking your question 3. Receiving an answer Registered members: * See fewer ads. * And much more..
|
| Want to know how to post a question? click here | Having problems with spyware and pop-ups? First Steps |
|
|||||||
| Programming A discussion forum for programs and programming used in tech-related businesses. |
![]() |
|
|
LinkBack | Thread Tools |
|
|
#1 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 18
OS: Windows 2005
|
Hi All,
I need a batch script to ftpthe files in a folder (Windows Server) to Unix environment. Is it possible to ftp without creating the filelist. Do we have command to transfer all the files in the folder to UNIX without creating a filelist? Any other scripting language is also welcome.. but the requirement is to transfer the files without creating filelist. Thanks in advance. |
|
|
|
| Important Information |
|
Join the #1 Tech Support Forum Today - It's Totally Free!
TechSupportForum.com is a leading support website for your computer needs. We offer free, friendly and personalized computer support. Why pay to have your computer fixed when you can do it for free. Join TechSupportforum.com Today - Click Here |
|
|
#3 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 815
OS: MS-Dos 6.22 - Win7
|
Re: Batch Script to FTP
Welcome to TSF!
This will upload all files in the specified local folder (_lcd variable) to the specified folder on the FTP server (_FTPRoot variable). It doesn't create a file list, just uploads everything. You do have to create the script file. Note that the username and password are stored in the file, so anyone with read access to the folder that contains the batch file can see the username and password. You can always prompt for the UN/PW when the batch file is run if needed. Edit the server name, username, and password as needed Specify the Local folder and the FTP Server folder as needed Code:
@echo off
SetLocal
:: Set local folder you want to upload here.
Set _lcd= C:\Folder to upload
:: Will use current folder as a Temp folder for the FTP Script
Set _tmpfld=%~dp0
Set _tmpfld=%_tmpfld:~0,-1%
:: Set the Folder on the FTP server that you want to upload to
Set _FTPRoot= /
>"%_tmpfld%\ftpcmds.}t{" Echo open ftp.server.com
>>"%_tmpfld%\ftpcmds.}t{" Echo Username
>>"%_tmpfld%\ftpcmds.}t{" Echo password
>>"%_tmpfld%\ftpcmds.}t{" Echo cd "%_FTPRoot%"
>>"%_tmpfld%\ftpcmds.}t{" Echo lcd "%_lcd%"
>>"%_tmpfld%\ftpcmds.}t{" Echo binary
>>"%_tmpfld%\ftpcmds.}t{" Echo mput *.*
>>"%_tmpfld%\ftpcmds.}t{" Echo quit
ftp -v -i -s:"%_tmpfld%\ftpcmds.}t{"
:: Delete the script
Del "%_tmpfld%\ftpcmds.}t{"
EndLocal
Jerry
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
|
|
#4 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 18
OS: Windows 2005
|
Re: Batch Script to FTP
Hi Jerry,
I am using the following script but it does not ftp the xml files. @echo off SetLocal :: Set local folder you want to upload here. Set _lcd=\\lxtrs416.mgroupnet.com\Archives\script\test06\DSR :: Will use current folder as a Temp folder for the FTP Script Set _tmpfld=%~dp0 Set _tmpfld=%_tmpfld:~0,-1% :: Set the Folder on the FTP server that you want to upload to Set _FTPRoot= /bcmf/SSA/BLUECUBE/intin/DSR >"%_tmpfld%\ftpcmds.}t{" Echo open 89.108.1.19 >>"%_tmpfld%\ftpcmds.}t{" Echo user >>"%_tmpfld%\ftpcmds.}t{" Echo user >>"%_tmpfld%\ftpcmds.}t{" Echo cd "%_FTPRoot%" >>"%_tmpfld%\ftpcmds.}t{" Echo lcd "%_lcd%" >>"%_tmpfld%\ftpcmds.}t{" Echo binary >>"%_tmpfld%\ftpcmds.}t{" Echo mput *.* >>"%_tmpfld%\ftpcmds.}t{" Echo quit ftp -v -i -s:"%_tmpfld%\ftpcmds.}t{" :: Delete the script Del "%_tmpfld%\ftpcmds.}t{" EndLocal Kindly correct if i were wrong anywhere.. |
|
|
|
|
|
#6 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 815
OS: MS-Dos 6.22 - Win7
|
Re: Batch Script to FTP
You're welcome.
![]() Glad you spotted that; an extra space can be a pain to find
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
|
|
#7 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 18
OS: Windows 2005
|
Re: Batch Script to FTP
Hi i have an enhance to the existing code.
While the FTP completes the same sorce xmls need to be archived to C:\Myfiles\Archive. This is a transfer between Windows server only. To summarize 1. The files from source should be Uploaded to UNIX server 2. Archived in the folder (under Windows Server) 3. deleted from Source directory. Kindly advice me. Regards, Coddy. |
|
|
|
|
|
#8 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 815
OS: MS-Dos 6.22 - Win7
|
Re: Batch Script to FTP
Would probably be better to copy them after uploading rather than trying to do it at the same time. You could start a 2nd batch file to do the archiving just before the FTP starts, but depending on the setup, you might not be able to copy a file that is currently being uploaded.
I'd expect the LAN to be faster than an FTP Upload, but that might not be the case, so you'd need which ever script is NOT going to do the deleting to create a flag file when it is done, and the other script would have to check for that file before deleting. Easiest to just add the two red lines shown below. type xcopy /? for a list of switches to see if you need to add any others. You could also use Move instead of Xcopy, then you wouldn't need the Delete. Code:
ftp -v -i -s:"%_tmpfld%\ftpcmds.}t{"
:: Delete the script
Del "%_tmpfld%\ftpcmds.}t{"
Xcopy /CIQ "%_lcd%\*.xml" C:\Myfiles\Archive
Del /F /Q "%_lcd%\*.xml"
EndLocal
Jerry
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
|
|
#9 (permalink) |
|
Registered User
Join Date: May 2009
Posts: 18
OS: Windows 2005
|
Re: Batch Script to FTP
hey when i try upload files with this method i have got a problem...
this script is working great with few number of files... but when it comes to files like 500 and more only 100-125 files are getting FTPed..... Could please help me on this???? Could there be any other reason for this problem...... Kindly help me.. |
|
|
|
|
|
#10 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 815
OS: MS-Dos 6.22 - Win7
|
Re: Batch Script to FTP
Are you getting any error messages? Or does the FTP session just quit?
Any chance the FTP Server has a time limit on connections?
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
|
|
#12 (permalink) |
|
Registered User
Join Date: Jun 2009
Posts: 1
OS: XP Pro
|
Re: Batch Script to FTP
The ftp script works great as long as the _tmpfld is a path thas does not contain any spaces in the path name. How can you add quote marks to the path. Vista can be set where you can not write C:\. so you need to write the _tmpfld to the desktop or my documents.
|
|
|
|
|
|
#13 (permalink) |
|
TSF Enthusiast
Join Date: Mar 2009
Location: Portland, OR
Posts: 815
OS: MS-Dos 6.22 - Win7
|
Re: Batch Script to FTP
_tmpfldr can contain spaces. It is quoted everyplace it needs to be: "%_tmpfld%\ftpcmds.}t{ " .
If you can't write to C:\, you can't put the batch file there in the first place. Since it sets _tmpfldr to the same folder that contains the batch file, not being able to write to C:\ won't be a problem. Unless you change security settings after putting the file there of course. Afraid I don't have any new ideas on why the connection would drop though.
__________________
Microsoft MVP - Windows Desktop Experience Of course I know all the answers; I just don't always match the answers to the right questions. Rated R for Violence -- When your PC flies through a window, that's violent, right? |
|
|
|
![]() |
| Thread Tools | |
|
|