Page 1 of 1 1
Topic Options
#128567 - 2004-10-28 05:14 PM Trapping FTP logon failure
Stanley Offline
Starting to like KiXtart

Registered: 2004-06-03
Posts: 130
Loc: Upstate NY, USA
Good morning all:
I am attempting to trap a logon error in an FTP session.
KIX ver 4.22
WIN 2k Pro
Kixtarter 1.85

Code:
  

BREAK ON CLS

SHELL "%COMSPEC% /C FTP -i -s:C:\FTP\TESTOUT.txt > C:\errorlogs\TESTOUT.LOG"

? "@@ERROR: "+@ERROR
? "@@SERROR: "+@SERROR

IF @ERROR <> 0
? "@@ERROR : "+@ERROR+"@@SERROR : "+@SERROR
ENDIF


The FTP command file is
Code:
 

open FTPServer.Domain.com
CorrectUserCode
IncorrectPassword
CD TEST
lcd \
lcd FTP\test
MPUT *.txt
bye




OUTPUT

Login failed.

@ERROR: 0
@SERROR: The operation completed successfully.

OUTPUT
I have put an incorrect password in the FTP command file, but @ERROR returns "Operation completed successfully".
Yet "Login Failed." is printed to the screen. I would like to be able to trap the "Login Failed".
Thank you in advance for any help.


Thank you Richard and Howard for your suggestions, but I decided to try something different.

Code:
 

BREAK ON CLS

DIM $filename,$line,$login

;Create a list of files to be FTPed
SHELL "%COMSPEC% /C DIR C:\test /b /l > filelist.txt"

;FTP files and pipe output to text file
SHELL "%COMSPEC% /C FTP -i -s:C:\ftpcmds.txt > C:\ftpoutput.txt"

OPEN(1,"C:\test\filelist",2)

$filename = READLINE(1)

;Set login to failed
$login = 1

WHILE @ERROR = 0

OPEN(2,"C:\ftpoutput.txt",2)

$line = READLINE(2)

WHILE @ERROR = 0

IF INSTR($line,$filename)

;Must have at least logged in
$login = 0

;Read the next line
$line = READLINE(2)

;Then the file was FTPed
IF INSTR($line,"Transfer complete")

? "FTP Verfied for "+$filename

ELSE

? "FTP failed for "+$filename

ENDIF

ENDIF

$line = READLINE(2)
LOOP

$ = CLOSE(2)

$filename = READLINE(1)

LOOP

IF $login = 0
? "Login succeeded"
ELSE
? "Login failed "
ENDIF

$ = CLOSE(1)



I have tested for all cases of errors I could think of. I would appreciate any commmments , suggestions, or downright laughter at my amateur attempt.


Edited by Stanley (2004-11-01 10:14 PM)
_________________________
Taxation WITH representation isn't so hot, either!

Top
#128568 - 2004-10-28 05:25 PM Re: Trapping FTP logon failure
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Try something like this:
Code:
SHELL "%COMSPEC% /C FTP -i -s:C:\FTP\TESTOUT.txt > C:\errorlogs\TESTOUT.LOG 2>C:\errorlogs\TESTERR.LOG"
SHELL 'FIND /I "failed" C:\errorlogs\TESTERR.LOG'
? "@@ERROR: "+@ERROR
? "@@SERROR: "+@SERROR


Top
#128569 - 2004-10-29 03:40 AM Re: Trapping FTP logon failure
Howard Bullock Offline
KiX Supporter
*****

Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
The FTP method in Win32Admin.DLL will return the error.

http://home.comcast.net/~habullock/kix_solutions.htm

http://home.comcast.net/~habullock/Win32Admin.htm#Miscellaneous
_________________________
Home page: http://www.kixhelp.com/hb/

Top
#128570 - 2004-11-02 08:18 PM Re: Trapping FTP logon failure
Stanley Offline
Starting to like KiXtart

Registered: 2004-06-03
Posts: 130
Loc: Upstate NY, USA
Thank you Richard and Howard for your suggestions, but I decided to try something different.

Code:
 BREAK ON CLS

DIM $filename,$line,$login

;Create a list of files to be FTPed
SHELL "%COMSPEC% /C DIR C:\test /b /l > filelist.txt"

;FTP files and pipe output to text file
SHELL "%COMSPEC% /C FTP -i -s:C:\ftpcmds.txt > C:\ftpoutput.txt"

OPEN(1,"C:\test\filelist",2)

$filename = READLINE(1)

;Set login to failed
$login = 1

WHILE @ERROR = 0

OPEN(2,"C:\ftpoutput.txt",2)

$line = READLINE(2)

WHILE @ERROR = 0

IF INSTR($line,$filename)

;Must have at least logged in
$login = 0

;Read the next line
$line = READLINE(2)

;Then the file was FTPed
IF INSTR($line,"Transfer complete")

? "FTP Verfied for "+$filename

ELSE

? "FTP failed for "+$filename

ENDIF

ENDIF

$line = READLINE(2)
LOOP

$ = CLOSE(2)

$filename = READLINE(1)

LOOP

IF $login = 0
? "Login succeeded"
ELSE
? "Login failed "
ENDIF

$ = CLOSE(1)





I have tested for all cases of errors I could think of. I would appreciate any commmments , suggestions, or downright laughter at my amateur attempt.
_________________________
Taxation WITH representation isn't so hot, either!

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2220 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.064 seconds in which 0.036 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org