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:
* Get free support
* Communicate privately with other members (PM).
* Removal of this message
* 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
Go Back   Tech Support Forum > The IT Pro > Programming
User Name
Password
Site Map Register Donate Rules Blogs Mark Forums Read


Programming A discussion forum for programs and programming used in tech-related businesses.

Reply
 
LinkBack Thread Tools
Old 05-13-2009, 10:23 AM   #1 (permalink)
Registered User
 
Join Date: May 2009
Posts: 18
OS: Windows 2005


Pencil Batch Script to FTP

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.
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
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

Old 05-13-2009, 11:44 AM   #2 (permalink)
As you wish
 
TJ Belfiore's Avatar
 
Join Date: Mar 2009
Location: 530
Posts: 3,499
OS: 7 x64, XP x32


Re: Batch Script to FTP

I don't get it, why not just upload it, what's gonna happen?
__________________
Signature by TJ Belfiore

TJ Belfiore is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-14-2009, 03:36 AM   #3 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
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
HTH

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?
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-14-2009, 08:27 AM   #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..
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-14-2009, 08:33 AM   #5 (permalink)
Registered User
 
Join Date: May 2009
Posts: 18
OS: Windows 2005


Re: Batch Script to FTP

Jerry sorry for the previous reply its working fine now.. Thanks a lot..
There was a space in the line Set _FTPRoot= /bcmf/SSA/BLUECUBE/intin/DSR
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-14-2009, 04:56 PM   #6 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
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?
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-18-2009, 04:23 AM   #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.
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-20-2009, 02:26 AM   #8 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
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
HTH

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?
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-22-2009, 04:28 AM   #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..
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-22-2009, 03:55 PM   #10 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
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?
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 05-25-2009, 03:48 AM   #11 (permalink)
Registered User
 
Join Date: May 2009
Posts: 18
OS: Windows 2005


Re: Batch Script to FTP

It just transfered few xml files and the FTP session quits....
There is no time limit on the connections too....
Codesearcher is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 06-01-2009, 07:33 AM   #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.
TomE1 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Old 06-01-2009, 11:25 AM   #13 (permalink)
TSF Enthusiast
 
TheOutcaste's Avatar
 
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?
TheOutcaste is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -7. The time now is 08:33 AM.



Copyright 2001 - 2009, Tech Support Forum
Home Tips Plus | Outdoor Basecamp | Automotive Support Forum

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85