Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

italiano40

macrumors 65816
Original poster
Oct 7, 2007
1,080
0
NY
I am building this app that will download a txt file from a FTP with a command line command in it, and i want the program to run that command without opening a terminal how should i do this in cocoa
 
I'm not sure which part of this you are having trouble with, the FTP access or running the command.

For running of the command the C way to do it would be to call system() and pass in the command as a c-style string. If this needs to be spawned but not block your main thread you could either add a & to the end of the command, or fork and in the child run the system command.

For running the command the Cocoa way, NSTask is the way to go:
http://developer.apple.com/document...Classes/NSTask_Class/Reference/Reference.html

As far as the FTPing of a file, I'm not sure on that one. I will state that you should not use FTP but SFTP or another secure method of transmission. It's trivial to sniff FTP traffic, and in this case this would lead to someone being able to modify the file with the command to something like "rm -rf /users/*" and make you very unhappy.

-Lee
 
I'm not sure which part of this you are having trouble with, the FTP access or running the command.

For running of the command the C way to do it would be to call system() and pass in the command as a c-style string. If this needs to be spawned but not block your main thread you could either add a & to the end of the command, or fork and in the child run the system command.

For running the command the Cocoa way, NSTask is the way to go:
http://developer.apple.com/document...Classes/NSTask_Class/Reference/Reference.html

As far as the FTPing of a file, I'm not sure on that one. I will state that you should not use FTP but SFTP or another secure method of transmission. It's trivial to sniff FTP traffic, and in this case this would lead to someone being able to modify the file with the command to something like "rm -rf /users/*" and make you very unhappy.

-Lee

no i got the FTP down and i am think of switching to SFTP but i was also looking at e-mail, i just needed help with passing the command down to the command line, thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.