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
Solved

wget output in memory/variable

Posted on 2009-07-07
4
555 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
  • 2
4 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
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 opening and reading files in the C programming language.
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.

792 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