Hi,
The documentation on iFtpFileExist (in the WinInet extender) appears to be missing (or at least in my build of WinBatch.)
I have used this function previously and successfully - but now my sys admin rebuilt the FTP server - and it no longer works, always returning 0. (iFTPGet on the same file is successful.)
Questions:
1. Is iFtpFileExist a legit function, or should I use one of the UDFs found at:
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WIL~Extenders/WinInet+Check~if~FTP~File~Exists.txt
http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WIL~Extenders/WinInet+FTP~File~Exist.txt
If iFtpFileExist a legit function:
2. What might be causing iFtpFileExist to always return 0?
3. What is the underlying FTP call(s) used by iFtpFileExist?
Thanks,
-Ed Lecuyer
Product Manager, MyTopo's Terrain Navigator Pro.
Ed,
There is currently no released version of the WinInet Extender that supports a function called iFtpFileExist. This function has been requested to be added to future versions of this extender. I recommend using the code sample found here: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WIL~Extenders/WinInet+Check~if~FTP~File~Exists.txt
Answers:
- Use this UDF: http://techsupt.winbatch.com/webcgi/webbatch.exe?techsupt/tsleft.web+WIL~Extenders/WinInet+Check~if~FTP~File~Exists.txt
- No iFtpFileExist is not a current WinInet Extender function.
- The code included in the above link, uses the iFtpDirChange and iFtpFindInit functions to determine if a File Exists on a FTP server.
You can probably simply add the UDF and modify your script to call MyFtpFileExist instead of iFtpFileExist.
Hi Deana,
I don't remember when I downloaded the WinInet extender. I have wwint44i.dll version 44080.0.0 dated 3/9/2009.
I'm sure the iFtpFileExist function worked. In fact, I have a ton of compiled/released code that relies upon it. Unfortunately, its in the software's auto-update routine, so this will mean that my users will not get their next update.
Going forward, I can use the MyFtpFileExist UDF - but I'll have to figure out what broke the phantom iFtpFileExist function.
Thanks,
-Ed
Ed,
Based on some research of the extender dll, it looks like some undocumented version of that function may have been available starting in version 44079. As I understand it, the function has never been documented. However it does seem to exist in version 44079 up to, and including, the current version 44083. Here it is a code sample using the undocumented function:
AddExtender( 'WWINT44I.DLL', 44079 ) ; includes minimum version.
host = 'ftp.winbatch.com'
user = ''
pswd = ''
ftppath = '/wwwftp/IntroToProgramming'
filename = 'IntroToProgramming.pdf' ;EXISTS
;filename = 'xxxx' ;DOES NOT EXIST
Pause('WinInet Version', iVersion( ))
tophandle = iBegin( 0, '', '' )
conhandle = iHostConnect( tophandle, host, @FTP, user, pswd )
If conhandle == 0
Message( 'ERROR', 'Unable to connect to host' )
Exit
EndIf
ret = iFtpFileExist(conhandle, ftppath, filename)
If ret==0
Message( 'iFtpFileExist', 'File Does not Exist' )
Else
Message( 'iFtpFileExist', 'File Exists' )
Endif
iClose( conhandle )
iClose( tophandle )
Exit
So it looks like you should still be able to use the function ( in the current version ) even though it is undocumented. I will look into getting the function documented for the next release.
iFtpFileExist
Checks if a file exists on an FTP Server
Syntax:
iFtpFileSize( connect-handle, ftp-path, filename )
Parameters:
(i) connect-handle: valid handle to ftp session, returned from iHostConnect.
(i) ftp-path: path of the file you want to check on the remote system.
(s) filename: name of the file to check on the remote system.
Returns:
(i) @True if the file exists; @False is the file does not exist.
You mentioned that function no longer works after an ftp rebuild. I suspect its a file path problem. Make sure both directory and filename are correct. Also make sure you are not suppressing errors using ErrorMode or IntControl 73.
We found the issue with our FTP server and iFtpFileExist.
The failure was a combination of user permissions for the parent directory for the user. It turns out that iFtpFileExist needs access to the root directory as well so it can CWD into the desired folder.
Thanks for all your help,
-Ed
Quote from: Ed Lecuyer on July 23, 2013, 11:01:03 AM
We found the issue with our FTP server and iFtpFileExist.
The failure was a combination of user permissions for the parent directory for the user. It turns out that iFtpFileExist needs access to the root directory as well so it can CWD into the desired folder.
Thanks for all your help,
-Ed
Excellent. Glad to hear you have it working again.
Quote from: Ed Lecuyer on July 23, 2013, 11:01:03 AMIt turns out that iFtpFileExist needs access to the root directory as well so it can CWD into the desired folder.
Nice detective work!
I bet that wasn't easy.
-Kirby