Question Locked

How to check the return code for ftp in windows nt scripting

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi,
I have a windows script which ftp's the files from one location to another unix location
I need to check whether the ftp was successful or not.
How can I do the needful?
Here is the code

echo FTP to userevr - File Verification Started >>%LOGFILE%

IF NOT EXIST D:\rs_survey_result.txt GOTO DoNotFTP

IF NOT EXIST D:\rs_survey_error.txt GOTO DoNotFTP

IF NOT EXIST D:\rs_scheduled_survey.txt GOTO DoNotFTP

IF NOT EXIST D:\rs_scheduled_survey_set.txt GOTO DoNotFTP

echo FTP to userevr - All files are present >>%LOGFILE%

ftp -s:D:\FTPto.sh >>%LOGFILE%
echo %errorlevel% >>%LOGFILE%

echo FTP to userevr Completed >>%LOGFILE%
echo. |time |find "current" >>%LOGFILE%

code for FTPto.sh is as follows :-

open userver
test
teset12010
cd out
put D:\rs_survey_result.txt
put D:\rs_survey_error.txt
put D:\rs_scheduled_survey.txt
put D:\ rs_scheduled_survey_set.txt
bye

3 replies

by robo_dev

if so, then you would need to compare file dates or perhaps have another process that moves/erases the files when they are used.

if exist D:\rs_survey_result.txt goto yes
goto no
:yes
echo file exists
goto end
:no
echo file not there
goto end
:end

by tony hopkinson

and check for the correct response code was the only way I ever trusted from shell scripting.
Passing back the ftp status status code as return (exit code) was always 'erm iffy in windows.

This discussion is closed to new replies.