1,105,334 Community Members

How to delete ftp file/directory using MacOSX API

Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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.

Member Avatar
dioioib
Junior Poster in Training
59 posts since Feb 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

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

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

Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
dioioib
Junior Poster in Training
59 posts since Feb 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
dioioib
Junior Poster in Training
59 posts since Feb 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
dioioib
Junior Poster in Training
59 posts since Feb 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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

Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Question Answered as of 2 Years Ago by dioioib
Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

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

Member Avatar
dioioib
Junior Poster in Training
59 posts since Feb 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
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.

Member Avatar
dannyniu
Newbie Poster
23 posts since Jun 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

And there's mount_ftp command

Member Avatar
dioioib
Junior Poster in Training
59 posts since Feb 2011
Reputation Points: 4 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
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.

You
This question has already been solved: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: