sunhux
asked on
Windows .bat .cmd batch script needed to test ftp connection
Needed a Windows XP .bat or .cmd script which does the following
(below are the pseudo codes) :
ftp a.b.c.d <<EOF
(if the ftp fails, ie does not even prompt for username in the next step,
then echo "pls check ftp server is running on a.b.c.d" or firewall rule
is permissioned & prompt user to hit ENTER to continue)
username : myftpid
password: myftpassword
(if the password authentication above fails, echo "pls check the userid
& password entered is correct or request for password reset" &
prompt user to hit ENTER to continue)
ftp> cd directory_A
ftp> dir
(if the dir command fails to list out any outputs, then echo "the firewall
may not have permissioned for ftp-data traffic, escalate to Netwk support",
& prompt user to hit ENTER to continue)
ftp> put testfile
(if the above put fails echo "there could be a write permission problem
of the directory at remote end" & prompt user to hit ENTER to continue)
ftp> delete testfile
ftp> quit
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks vm Bill, that helps.
Would you be able to find out the different %ERRORLEVEL% codes &
based on these error codes (for network inaccessible/firewall blocks,
ftp server not started on remote end, ftp-data not permissioned though
ftp traffic is permissioned, incorrect userid/password and no permission
to write to remote destination directory), echo out the messages accordingly
These are the errorlevel values returned by ncftpget:
ncftpget returns the following exit values:
0. Success.
1. Could not connect to remote host.
2. Could not connect to remote host - timed out.
3. Transfer failed.
4. Transfer failed - timed out.
5. Directory change failed.
6. Directory change failed - timed out.
7. Malformed URL.
8. Usage error.
9. Error in login configuration file.
10. Library initialization failed.
11. Session initialization failed.
If you wanted to look for other things I think you would have to search the like file with something like FINDSTR looking for certain error messages.
~bp
ncftpget returns the following exit values:
0. Success.
1. Could not connect to remote host.
2. Could not connect to remote host - timed out.
3. Transfer failed.
4. Transfer failed - timed out.
5. Directory change failed.
6. Directory change failed - timed out.
7. Malformed URL.
8. Usage error.
9. Error in login configuration file.
10. Library initialization failed.
11. Session initialization failed.
If you wanted to look for other things I think you would have to search the like file with something like FINDSTR looking for certain error messages.
~bp
ASKER
thanks
Welcome.
~bp
~bp
ASKER
Slight correction:
ftp> delete testfile
ftp> quit
ftp> EOF
& if the whole ftp session's screen display can be logged into a
file ftp_yyyyddmmhhmmss, that would be ideal