We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,708 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

How to delete ftp file/directory using MacOSX API

As you can see from the title, I'm suffering the problem. developer.apple.com didn't provide much information about this, I have to ask for solution somewhere else.
I already know how to up/down-load files and create directories, but the official reference doesn't say how to undo it.
I hope some one can tell me how to achieve this goal, or how to mount a ftp server as a local disk.
Thanks.

2
Contributors
13
Replies
2 Months
Discussion Span
1 Year Ago
Last Updated
14
Views
Question
Answered
dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Mounting ftp as a local disk can be done using SSHFS.

http://en.wikipedia.org/wiki/SSHFS

dioioib
Junior Poster in Training
61 posts since Feb 2011
Reputation Points: 14
Solved Threads: 2
Skill Endorsements: 0

I'd very much like use native MacOSX API, rather than something "foreign".

dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Looks like you are going to have to subclass the CFNetworking classes. Try reading about the Undo Architecture first.

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/UndoArchitecture/Articles/UndoManager.html#//apple_ref/doc/uid/20000205-CJBDJCCJ

I assume you have already read this:

https://developer.apple.com/library/mac/#documentation/Networking/Conceptual/CFNetwork/Concepts/Concepts.html

Another idea is to just move the files to a Trash dir until the client logs off then permanently erase the files.

dioioib
Junior Poster in Training
61 posts since Feb 2011
Reputation Points: 14
Solved Threads: 2
Skill Endorsements: 0

Another option is to use a script to SSH to the remote machine then use your standard terminal commands "mount /dev/<whatever disk you want> /Volumes/<your newly created dir name for the remote disk>"to mount the volume to /Volumes/<your newly created dir name for the remote disk>

For the tunnel:
SSH user@host -p<servers port default is 22 you might want to setup a port forward on your router>

for more information on SSH on OSX type man ssh in terminal.

dioioib
Junior Poster in Training
61 posts since Feb 2011
Reputation Points: 14
Solved Threads: 2
Skill Endorsements: 0

No. I just want something like the remove(char*) in stdio.h.
I can't make any more clear.

dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Then as I stated your going to need to write that function / class yourself.

Your asking for solutions which I have given you several on how to mount the remote disk locally but you rejected the ideas because they are not an easy cookie cutter solution wrapped in an apple framework. What you are asking for is not something as simple as remove(char *).

Have you read/downloaded the simple ftp example code? https://developer.apple.com/library/ios/#samplecode/SimpleFTPSample/Introduction/Intro.html#//apple_ref/doc/uid/DTS40009243

dioioib
Junior Poster in Training
61 posts since Feb 2011
Reputation Points: 14
Solved Threads: 2
Skill Endorsements: 0

I just want a solution in pure C/Obj-C solution, without shell scripts or any other language.
I'd also like the solution to be platform-insenstive, without the conversion like AppKit to UIKit.
And by undo I actually meant to really remove it even the file was already there without uploading.

Thank you anyway, though the example's in iOS, I was able to download its SDK.

dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

I've done a research my self finding that there really isn't such API can do this.
I think the MacOSX itself and many other BSDs' not designed for such a purpose which is:
to operate a FTP server from remote. Rather, they're designed to be a server to delete them by itself.
I think this could be the best answer to why there isn't how
to delete ftp file/directory using MacOSX API.

dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Question Answered as of 1 Year Ago by dioioib

Besides, SSH doesn't work on windows-based servers that have no ssh installed.

dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

you are joking right? of course it doesn't. It's open source and has been installed on every server i have ever worked with. So install it. Wow, that post is unreal.

if you want to jeopardize a security sluth like me sniffing your data packets go right ahead and use something less secure.

dioioib
Junior Poster in Training
61 posts since Feb 2011
Reputation Points: 14
Solved Threads: 2
Skill Endorsements: 0

Okay I found it. Use system() to run the ftp command in the /usr/bin.
Example: system("ftp 112.125.58.58");
Just like its done in terminal.

dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

And there's mount_ftp command

dannyniu
Newbie Poster
20 posts since Jun 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

This is no different then using a shell script to run SSH and SFTP. Using FTP is just a lot less secure. Do yourself a major favor and run it on a non-standard port number and or use port forwarding through your router. That will offer you some protection using standard FTP. But seriously consider switching to SSH now that you are essentially doing what I suggested in the first place.

Good luck.

dioioib
Junior Poster in Training
61 posts since Feb 2011
Reputation Points: 14
Solved Threads: 2
Skill Endorsements: 0

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0982 seconds using 2.74MB