Lasso Soft Inc. > Home

[FTP_DeleteFile]

LinkFTP_DeleteFile
AuthorGary Sprague
CategoryUtility
Version8.5.x
LicensePublic Domain
Posted18 Jun 2008
Updated18 Jun 2008
More by this author...

Description

Lasso's FTP tags are very useful, but I've long been wanting a Delete tag so that I can manage content on the FTP servers I access.

This tag provides that easy method.

Username and Password are optional if you have an FTP server that does not require login. (How dangerous is that!)

Sample Usage

FTP_DeleteFile(
 -url      = 'ftp://ftp.example.com/dir/a_file.zip',
 -username = 'myusername',
 -password = 'mypassword' );

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

size) == 0, -9960, 'FTP_DeleteFile: -URL parameter requires full URL including ftp://');
			
			local(
				'_serv' = #_ua->(get:3),
				'_dirs'	= (#_ua->(get:4) + '/'),
				'_file'	= #_ua->(get:5)
				);
			
			local('_ftp'= (net));
			
			#_ftp->(settype:Net_TypeTCP);
			
			#_resp = #_ftp->(Connect: #_serv, 21);
			#_read = #_ftp->(Read:1024);
			
			if(local_defined('Username') == true && #Username != '');
			
				#_resp = #_ftp->(Write:'USER ' + #Username + '\n');
				#_read = #_ftp->(Read:1024);
				fail_if( string( #_read )->beginswith( '500' ), -9960, 'No username provided.' );
				
				if(local_defined('Password') == true && #Password != '');
					#_resp = #_ftp->(Write:'PASS ' + #Password + '\n');
					#_read = #_ftp->(Read:1024);
					fail_if( string( #_read )->beginswith( '530' ), -9960, 'Invalid username or password.' );
				/if;
				
			/if;
			
			#_resp = #_ftp->(Write:'CWD '  + #_dirs + '\n');
			#_read = #_ftp->(Read:1024);
			fail_if( string( #_read )->beginswith( '550' ), -9984, 'Remote directory not found.' );
			fail_if( string( #_read )->beginswith( '530' ), -9960, 'Access Denied. Login required.' );
			
			#_resp = #_ftp->(Write:'DELE ' + #_file + '\n');
			#_read = #_ftp->(Read:1024);
			fail_if( string( #_read )->beginswith( '550' ), -9984, 'Remote file not found.' );
			fail_if( string( #_read )->beginswith( '530' ), -9960, 'Access Denied. Login required.' );
			
			#_resp = #_ftp->(Write:'QUIT\n');
			#_read = #_ftp->(Read:1024);
			
			#_ftp->close;

			handle_error;
				error_push;
				#_ftp->close;
			/handle_error;

		/protect;

		error_pop;

	/define_tag;
?>

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft