To run FTP in Windows XP

Please find attached is a ftp batch file that run on UNIX. Please help me to convert this batch so that it can run on Windows XP..
Who is Participating?
Gerwin Jansen, EE MVEConnect With a Mentor Topic Advisor Commented:
I would suggest that you use WinSCP in batch mode as an FTP client. You can use this client to setup your connection and then use the command line version to send your file. Checking the server can be done using 'ping', assuming that's what you mean by 'available'. What do you mean by 'whether the file is ready or not'? I don't understand this.

Here is a basic script, note that you have to build the ftpscript.txt file using the GUI first.
rem 1 - Check availability
ping -n 1 <ftp server> >nul 2>nul

rem 2 - Check file readiness
rem TBD - see question above

rem 3 - FTP file
winscp.exe /console /script=ftpscript.txt
echo FTP sending OK >> ftplog.txt
move <orig folder>\<file> <archive folder>/
goto END

echo FTP error sending file >> ftplog.txt
goto END

echo File not ready >> ftplog.txt
goto END

echo FTP server unavailable >> ftplog.txt


Open in new window

Gerwin Jansen, EE MVETopic Advisor Commented:
Hi, we can help you but since the script is depending for a lot of specific Unix commands and paths I suggest you install Cygwin first on your Windows XP machine. What do you want to do with paths like this that are in the script:








Let me know when you've installed Cygwin.
RizuanAuthor Commented:
I probably not able to install Cygwin since my laptop is the company property. Basically what i want is windows batch file that able to ftp a file to a server.

First it will check whether the server is available or not. If yes go to the next step. If not, it will log the error.

The next step is to check whether the file is ready or not. If yes go to the next step. If not, it will log the error.

The 3rd step is to ftp the file to the server. If success, then move the file from the original folder to archive folder with date and time stamp.

If not, then log the error.

For more details, you can refer to the file that i have attached in my post.
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Steve KnightIT ConsultancyCommented:
I'd use this for ftp if you are happy with the built in ftp.exe client:

The easiest method is #3 as it keeps it all in the same file.

I started writing up what you need but frankly there are loads of parts to it and would suggest maybe you should split it up... your unix file explains what needs doing OK but what you are asking for frankly is a bit much of a question here if you want a pre-written tested script, you are talking a good amount of time to do it justice IMO if you want it belt and braces checking like in the unix script.

You are looking at I guess:
PING server to check it is up
Login to ftp server as test that ftp server is there, and that FTP user works
Check the local files exist to transfer
Run ftp script to transfer them.... one, five, hundred?  Are they in the same dir, subdirs etc?
Check it transferred OK
Get date into correct format ( )
Use that date to move to archive area if transfer was OK.

RizuanAuthor Commented:

Sorry for the late response. Actually i have tried the first checking which is to check the server availability but i don't understand why errorlevel is not working. No matter whether the condition is false or true, it keep on telling that FTP server unavailable in ftplog.txt.
Steve KnightIT ConsultancyCommented:
Unless this is on Windows 2000 (which didn't give an errorlevel from PING) then if the PING fails it will give errorlevel 1, otherwise errorlevel 1

You could also do:

rem 1 - Check availability
ping -n 1 x.x.x.x >nul 2>nul || goto FTP_UNAV


But like I said there are quite a few parts to your Q so probably best to concentrate on few bits at a time IMO.

Gerwin Jansen, EE MVETopic Advisor Commented:
I agree with dragon-it, work on 1 thing at a time.

Try the ping and echo command first from a command prompt:
ping <ftp server>

Open in new window

Sample output below, please post your output.

Ping request could not find host Please check the name and try again.


ping nas

Pinging nas [] with 32 bytes of data:
Reply from bytes=32 time=3ms TTL=64
Reply from bytes=32 time=2ms TTL=64
Reply from bytes=32 time=2ms TTL=64
Reply from bytes=32 time=1ms TTL=64

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 3ms, Average = 2ms

Steve KnightIT ConsultancyCommented:
As an example.... no matter what I PING by name I always get an answer... I use OpenDNS here and it responds with one of their server IP's to redirect browser to "friendly" page by default.  Side effect is PING xyzsa gives "OK".  PING of bad IP fails still of course.

So please try as suggested above, lets find that then part 2 etc.  If it comes to it maybe as second or more relatede questions because then other people pick them up too.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.