Notes FTP

I am having a problem FTP -ing files from the mainframe longer that 38 characters for some reason. I am using the NotesFTP script library and code from the sandbox. I am getting an error 304. The error is happening when I try to change the directory to aud.s.dlf.fdr.d013107.audfdrd6.gl155350. Yet the filename aud.t.dlf.fdr.d013107.audfdrd.gl155350 works(1 less character). Also, when I go to the command prompt on my machine and FTP that way, not using the Notes script code, I can FTP files over 38 characters in length, no problems.

I tried to look at the Win32 API but I can’t figure out where the problem is.

Does anyone have a clue? I appreciate any help.

Subject: Solved!

I figured out the problem finally. I thought I had already tried this but must not have.

In my code I changed the directory to an empty string, then changed it to the filename I was trying to get, then I used a .GetFile to the filename.

I did not need the .ChangeDirectory to the filename.

FType = Trim(Strright(fakedoc.cxfilechoose(i)," - "))

		FName = Trim(Strleft(fakedoc.cxfilechoose(i)," - ")) 

'		This will change to the root directory which needs to be because you come into the $XXXX directory

		.ChangeDirectory " "

		Print "...downloading " & FName & " .....please wait..."

		'.ChangeDirectory FName		Took this out 2/14/07 was causing problem	

		If FType = "ASCII" Then

			.GetFile |'| & FName & |'|, fakedoc.PCfilepath(0) & FName & ".CAG", FTP_TRANSFER_TYPE_ASCII 

		Else

			.GetFile |'| & FName & |'|, fakedoc.PCfilepath(0) & FName & ".CAG", FTP_TRANSFER_TYPE_BINARY

		End If

Subject: Notes FTP

Try using the FTP command from DOS. The problem is most likely being caused by your mainframe.

Subject: RE: Notes FTP

The FTP command from DOS works fine. It just does not work through the Notes script.

Subject: RE: Notes FTP

Sorry missed that in your orginal message. I can’t see how it could be anything in the API. There is nothing in the API that mentions a limitation on filenames.

Subject: Notes FTP

strange. For me it works with both directory names. Also, just for fun I created a directory with length of 72 characters. And it still works.

If you leave everything out of your code and just try a “hello world” code with connection directory change and disconnect. Does also fail?

And are you saying you cannot change directory or you cannot send files with name longer than 38 chars?

Subject: RE: Notes FTP

Thanks for looking at that. Good idea…I simplified my code and re-ran it with no luck.

Here is my full code, it fails at the .ChangeDirectory FName:

On Error Goto Errhandler

Dim objFTP As NotesFTPSession

Dim session As NotesSession

Dim db As NotesDatabase

Dim fakedoc As NotesDocument

Dim ws As NotesUIWorkSpace

Dim item As NotesItem

Dim uidoc As notesuidocument

Dim doc As NotesDocument	

Dim FType As String

Dim FName As String

Dim HasAccess As Variant

Dim GroupAccess As Variant

Dim SupportAccess As Variant



Set session = New NotesSession

Set ws = New NotesUIWorkSpace

Set db = session.CurrentDatabase

Set fakedoc = db.createdocument

Set objFTP=New NotesFTPSession

Set uidoc = ws.CurrentDocument

Set doc = uidoc.document

Set item = doc.GetFirstItem("FTPHistory")



'check to make sure the person can download these files

'anyone with designer or greater access and the requestor, FS and any added names in the FTPAccess field

HasAccess = Evaluate(|@IsMember(@Name([CN];@UserName);FieldSupervisor:Requestor:FTPAccess)|,doc)

'this code enables groups to be entered into the FTPAccess field

GroupAccess = Evaluate(|@ismember(FTPAccess;@usernameslist)|,doc)

SupportAccess =  Evaluate(|@IsMember("[Support Group]";@UserRoles)|)



If HasAccess(0) = "1" Or GroupAccess(0) = "1" Or SupportAccess(0) = "1" Then

Else

	Msgbox "You do not have sufficient access to download files from " & _

	"this request. You must be the Requestor, Field Supervisor or listed in the Additional " & _

	"Staff Needing Access field.", 0 +16, "process cancelled"   

	Exit Sub

End If



If Trim(doc.childRN(0)) = "" Then

	Msgbox "There are no files to download", 0 +64, "process cancelled"

	Exit Sub

End If	



fakedoc.cxFilename = doc.cxfilename

fakedoc.cxFileType = doc.cxfiletype

fakedoc.PassWord = ""

fakedoc.LogonID = ""	

fakedoc.PCfilepath = ""



If ws.dialogbox("DLB-FTPinfo",True,True,False,False,False,False,"FTP Input information",fakedoc,False) = False Then

	Goto Cleanup

End If



With objFTP

	.Connect myserver, fakedoc.LogOnID(0), fakedoc.PassWord(0), 0

	For i = 0 To Ubound(fakedoc.cxfilechoose)	

		FType = Trim(Strright(fakedoc.cxfilechoose(i)," - "))

		FName = Trim(Strleft(fakedoc.cxfilechoose(i)," - ")) 

'		This will change to the root directory which needs to be because you come into the $XXXX directory

		.ChangeDirectory " "

		Print "...downloading " & FName & " .....please wait..."

		.ChangeDirectory FName			

		If FType = "ASCII" Then

			.GetFile |'| & FName & |'|, fakedoc.PCfilepath(0) & FName & ".CAG", FTP_TRANSFER_TYPE_ASCII 

		Else

			.GetFile |'| & FName & |'|, fakedoc.PCfilepath(0) & FName & ".CAG", FTP_TRANSFER_TYPE_BINARY

		End If

		

	Next

	

	.Disconnect

	

	'create download history doc

	Dim newdoc As NotesDocument

	Set newdoc = db.CreateDocument

	newdoc.form = "FTPHistory"

	newdoc.FTPName = session.CommonUserName

	newdoc.FTPfilepath =  fakedoc.pcfilepath(0)

	newdoc.FTPTime = Now

	newdoc.ControlNumber = doc.ControlNumber(0)

	Call newdoc.Save(True, False, True)

	

	

	Messagebox "Your file(s) have been downloaded successfully to "& fakedoc.pcfilepath(0) & ". The support request will now be closed.", 0+48, "Process Complete"

'	Call item.appendtotextlist(Cstr(Now) & " by " & session.CommonUserName & " to " & fakedoc.pcfilepath(0)) 

'	Call doc.Save(True,False,False)

	Call uidoc.Close		

	

End With

Cleanup:

If Not (objFTP Is Nothing) Then

	Delete objFTP

End If

Print " "

Exit Sub

ErrHandler:

Select Case Err

	

Case 302:	

	Msgbox "[Error #" & Cstr(Err) & "]: " & Error$ & " Check the $ ID and password you entered and re-try.  If this problem persists, please contact Lotus Notes Support" & _

	" for assistance.", 48, "NotesFTP Error"

Case 304 :

	Msgbox "[Error #" & Cstr(Err) & "]: " & Error$ & " The filename(s) listed on this request may be incorrect, please contact the Assigned to (" & doc.Assignto(0) & _

	") for assistance.", 48, "NotesFTP Error"

Case Else

	Msgbox "[Error #" & Cstr(Err) & "]: " & Error$ ,48, "NotesFTP Error"

End Select	

Resume Cleanup

Subject: RE: Notes FTP

not simple enough by far :slight_smile:

for all I can tell it fails on statement:

	.ChangeDirectory " "

from your comment I suspect you meant to have something like:

	.ChangeDirectory "/"

Subject: RE: Notes FTP

Sorry, the code I posted is my original code, When I simplified, I took out dialog box, etc.

I looked in MSDN site and it was suggested to use the GetLastError function to track down the exact error. I was not sure how to add that so I added another they suggested to the Script Library where I was having the error:

(from the script library)

’ changes current directory on FTP host

Sub ChangeDirectory(sDir$)	

	

	' raise error if directory could not be changed

	If FtpSetCurrentDirectory(Me.hConnection, sDir$) = False Then

		Dim lErr As Long, sErr As String, lenBuf As Long

'get the required buffer size

		InternetGetLastResponseInfo lErr, sErr, lenBuf

'create a buffer

		sErr = String(lenBuf, 0)

'retrieve the last respons info

		InternetGetLastResponseInfo lErr, sErr, lenBuf

'show the last response info

		Msgbox "Error " + Cstr(lErr) + ": " + sErr, 0+16

		

		

		Error NOTESFTP_SETDIR_FAILED, "Could not set current directory on host."

	End If

	

End Sub

When adding this, I get the error 501 Invalid directory name - too large

I do not get the error at .ChangeDirectory " "

But I do get a 550 error if I put in what you suggested .ChangeDirectory ""

maybe there is something up with my wininet.dll file?

Subject: RE: Notes FTP

GetLastError will not work from Lotus Script. It always returns 0 because a lot happened after your call to the FTP functions.

This is one of the main problems with NotesFTP.

Subject: RE: Notes FTP

Thanks Bruce, I did not know what was going on. The function InternetGetLastResponseInfo that I got from the msdn site, seems to be working but it appears this will be one of those problems I will just have to create a work-around. Thanks again for your help.

Subject: RE: Notes FTP

yes, there must be some differences. BTW I suggested forward slash not backslash; backslash does not work on my machine either except that it throws 305(?) error instead if 550.

I checked my laptop with XP Pro and my XP Home machine – both have the same version of wininet.dll 23-oct-2006, size 658944 bytes.

There seems to have been a lot of updates over years as different versions are present in patches – I counted 8 versions since 2004.

Subject: RE: Notes FTP

I mis-wrote that, I did try the forward slash, my machine does not like it for some reason, it error’s out even on the files under 38 characters. I checked my wininet.dll, I have 6 of them but the one in C:\WINNT\system32 is from 10/23/06 as well. The others I have are in C:\WINNT\ServicePackFiles\i386 from 2004, C:\OPTIONS\apps\corpapp\O2KCD1\System from 3/13/1998, C:\OPTIONS\apps\corpapp\o2kcd2sp3\System from 3/13/1998, and 2 others in a .CAB file. I am not versed on .dll files so I am not sure if that is out of the ordinary. Anyway, Thanks for your help on this Normunds, I appeciate your time.