Rizuan
asked on
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..
ftp-in-unix.txt
ftp-in-unix.txt
ASKER
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.
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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I'd use this for ftp if you are happy with the built in ftp.exe client:
http://scripts.dragon-it.co.uk/links/batch-ftp-scripting
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 (
https://www.experts-exchange.com/articles/OS/Microsoft_Operating_Systems/MS_DOS/Using-dates-in-batch-files-scripts.html )
Use that date to move to archive area if transfer was OK.
Steve
http://scripts.dragon-it.co.uk/links/batch-ftp-scripting
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 (
https://www.experts-exchange.com/articles/OS/Microsoft_Operating_Systems/MS_DOS/Using-dates-in-batch-files-scripts.html )
Use that date to move to archive area if transfer was OK.
Steve
ASKER
gerwinjansen,
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.
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.
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
etc.
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.
Steve
You could also do:
rem 1 - Check availability
ping -n 1 x.x.x.x >nul 2>nul || goto FTP_UNAV
etc.
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.
Steve
I agree with dragon-it, work on 1 thing at a time.
Try the ping and echo command first from a command prompt:
Sample output below, please post your output.
ping ftp.google.com
Ping request could not find host ftp.google.com. Please check the name and try again.
echo %ERRORLEVEL%
1
ping nas
Pinging nas [123.123.123.123] with 32 bytes of data:
Reply from 123.123.123.123: bytes=32 time=3ms TTL=64
Reply from 123.123.123.123: bytes=32 time=2ms TTL=64
Reply from 123.123.123.123: bytes=32 time=2ms TTL=64
Reply from 123.123.123.123: bytes=32 time=1ms TTL=64
Ping statistics for 123.123.123.123:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 3ms, Average = 2ms
echo %ERRORLEVEL%
0
Try the ping and echo command first from a command prompt:
ping <ftp server>
echo %ERRORLEVEL%
Sample output below, please post your output.
ping ftp.google.com
Ping request could not find host ftp.google.com. Please check the name and try again.
echo %ERRORLEVEL%
1
ping nas
Pinging nas [123.123.123.123] with 32 bytes of data:
Reply from 123.123.123.123: bytes=32 time=3ms TTL=64
Reply from 123.123.123.123: bytes=32 time=2ms TTL=64
Reply from 123.123.123.123: bytes=32 time=2ms TTL=64
Reply from 123.123.123.123: bytes=32 time=1ms TTL=64
Ping statistics for 123.123.123.123:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 3ms, Average = 2ms
echo %ERRORLEVEL%
0
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.
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.
log=/u01/app/airops/interf
errlog=/u01/app/airops/int
FTPlist=/u01/app/airops/in
templog=/u01/app/airops/in
inputDir=/u01/app/airops/i
archiveDir=/u01/app/airops
outputDir=/PROJECT_A/01_so
Let me know when you've installed Cygwin.