Thread: wget in c

  1. #1
    Registered User
    Join Date
    Mar 2011

    Question wget in c

    it is possible to send bash commands into a c application right?

    for example if i wanted to do a "wget" inside a c application how would this be done?

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Lookup popen()
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Mar 2011
    I tried this

    #include <stdio.h>
    #include <stdlib.h>
    int main(int argc, char *argv[])
    	popen("wget", "w");
    but got an error of

    sh: wget: command not found

    im using mac and have installed wget and can use it via console, any ideas?

  4. #4
    Join Date
    Dec 2007
    Use the full path to wget? Run "which wget" in the console to find it.

  5. #5
    Registered User
    Join Date
    Mar 2011
    ah, thank you that worked

    i installed via fink and it put it in a different dir not /usr/bin/wget as usual


    i tried this to get the location inside the c program

    popen("/usr/bin/which wget","w");

    however get no response, any ideas?


    never mind its just due to some messed up dirs on my mac lol
    Last edited by starternewb; 03-15-2011 at 05:42 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. URL help!
    By Liz320 in forum C Programming
    Replies: 15
    Last Post: 05-29-2009, 11:02 AM
  2. Writing to other files
    By Liz320 in forum C Programming
    Replies: 19
    Last Post: 05-26-2009, 06:41 PM
  3. Create an FTP Server
    By Epo in forum Networking/Device Communication
    Replies: 11
    Last Post: 01-22-2004, 09:17 PM
  4. Small issue with system()
    By Metal Man in forum C++ Programming
    Replies: 8
    Last Post: 10-21-2003, 01:33 PM