LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-24-2009, 01:55 PM   #1
matiasar
Member
 
Registered: Nov 2006
Location: Argentina
Distribution: Debian
Posts: 321
Blog Entries: 1

Rep: Reputation: 31
C++: how to upload files using ftp


I'm doing my firsts real life C++ programs... I made a program that process some mysql data and then creates xml files that must be uploaded to a remote ftp host.

I would appreciate very much if some of you could give me some advice on what's the best (and simplest) way to upload files with ftp from a C++ program.
I was thinking about doing some system call and running a bash script that can send the files. Is that a good way?


Thanks in advance,
Matías
 
Old 02-24-2009, 02:04 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,821

Rep: Reputation: 121Reputation: 121
You could call the shell and ftp the file, but another option is to use an ftp c++ library to send the file within your C++ code. google c++ ftp library, there are quite a few. libcurl is one that we use, it does ftp and many more.

I don't like calling the shell from my programs, because there are too many unknowns and its more difficult to determine what the problem was and how to recover from it.

Last edited by crabboy; 02-24-2009 at 02:26 PM.
 
Old 02-24-2009, 02:23 PM   #3
raconteur
Member
 
Registered: Dec 2007
Location: Slightly left of center
Distribution: slackware
Posts: 276
Blog Entries: 2

Rep: Reputation: 44
Quote:
Originally Posted by matiasar View Post
[...]I was thinking about doing some system call and running a bash script that can send the files. Is that a good way?[...]
No, it isn't. I recommend a good communications library (my favorite is libcurl). cURL (and libcurl) are very simple, stable, and flexible.
 
Old 02-25-2009, 05:01 AM   #4
matiasar
Member
 
Registered: Nov 2006
Location: Argentina
Distribution: Debian
Posts: 321

Original Poster
Blog Entries: 1

Rep: Reputation: 31
Thanks for the info folks!
I'll take a look to libcurl.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
upload using FTP WITHOUT overwriting existing/newer files HyperBlade Linux - Software 1 04-05-2008 11:10 PM
Not able to upload files through FTP in Linux thiagarn Linux - Newbie 3 02-24-2008 09:53 PM
upload files on ftp zafar466 Programming 2 12-14-2006 07:16 AM
Upload files to newly setup server via FTP Madone_SL_5.5 Linux - Newbie 4 10-27-2006 06:59 PM
how to make that ftp user could upload files, but not to delete! spotass Linux - Newbie 4 06-12-2004 06:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration