?
Solved

wget output in memory/variable

Posted on 2009-07-07
4
Medium Priority
?
560 Views
Last Modified: 2012-05-07
I am using wget in .c file and executing with system("wget http://example.com");
it is working fine but the output is saved to file or stderr how do i redirect to buffer in .c program
0
Comment
Question by:tittu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 1500 total points
ID: 24792977
Hi,
you can use a 'popen' call -
#include <stdio.h>

main()
{
  FILE *fptr;
  char line[130]; /* line from wget*/
   
  fptr = popen("wget http://example.com", "r"); /* Issue the wget command. */

/* Read a line */
  while ( fgets( line, sizeof line, fptr))
  {
    printf("%s", line);

/* or process the 'line' otherwise as needed */
  }
  pclose(fptr);
}
 
0
 
LVL 40

Expert Comment

by:evilrix
ID: 24793453
Have you considered using libcurl to do this?
http://curl.haxx.se/libcurl/

0
 

Author Comment

by:tittu
ID: 24824510
thanks
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24827532
Any reason for grade B?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
This article offers some helpful and general tips for safe browsing and online shopping. It offers simple and manageable procedures that help to ensure the safety of one's personal information and the security of any devices.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
Suggested Courses
Course of the Month13 days, 5 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question