Solved

wget output in memory/variable

Posted on 2009-07-07
4
549 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Several part series to implement Internet Explorer 11 Enterprise Mode
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…

708 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now