Solved

wget output in memory/variable

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
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…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use for-loops 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…

803 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