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 08-28-2007, 03:54 PM   #1
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Rep: Reputation: 57
gcc: libraries for copying files, ftp, data output ?


Learning gcc slowly. I am now with files and output. I would like to send my results to my internet other pc, via ftp. Has someone any idea ? thanks

Please find the code :

Quote:
#include "stdio.h"
#include "assert.h"
#include "complex.h"
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>


int main(int argc,
char **argv)
{
printf("Uploading\n");

execlp("ftp", "ftp", "10.1.1.56", "login@password", "file1tobeuploaded.zip", (char *) 0);


return 0;



}

Last edited by frenchn00b; 08-28-2007 at 05:41 PM.
 
Old 08-29-2007, 11:24 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
Unless the program you are invoking with execlp() gets all of it's information from the commandline, you will need to use something like popen() to invoke it, in order to feed the program its required standard input. See this page on Beej's Guide to UNIX IPC
--- rod.
 
Old 08-29-2007, 01:26 PM   #3
frenchn00b
Senior Member
 
Registered: Jun 2007
Location: E.U., Mountains :-)
Distribution: Debian, Etch, the greatest
Posts: 2,561

Original Poster
Rep: Reputation: 57
Quote:
Originally Posted by theNbomr View Post
Unless the program you are invoking with execlp() gets all of it's information from the commandline, you will need to use something like popen() to invoke it, in order to feed the program its required standard input. See this page on Beej's Guide to UNIX IPC
--- rod.

and could go gcc :

Code:
copy file1 file2
without any use of execlp ??

I need expert, gcc is really powerful.


looks like in this direction ....
Quote:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>

int main()
{
int pfds[2];
char buf[30];

if (pipe(pfds) == -1) {
perror("pipe");
exit(1);
}

printf("writing to file descriptor #%d\n", pfds[1]);
write(pfds[1], "test", 5);
printf("reading from file descriptor #%d\n", pfds[0]);
read(pfds[0], buf, 5);
printf("read \"%s\"\n", buf);
}
thank you, I am trying to understand. I had a good book of C, 2 years ago, but where it is ?

Last edited by frenchn00b; 08-29-2007 at 01:28 PM.
 
  


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
copying grows data jonaskoelker Linux - Software 1 08-06-2006 05:01 PM
gcc-libraries yashwantpinge Programming 3 11-22-2005 12:17 AM
Automatically Copying files from the ftp directory into the html directory swatward Linux - General 3 04-17-2005 10:55 PM
Issue copying data files from CD fryak Fedora 3 05-28-2004 11:49 AM
Saving gcc output files to new directory Fe98 Programming 3 12-08-2003 07:18 AM

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

All times are GMT -5. The time now is 01:39 AM.

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