wget in c

This is a discussion on wget in c within the C Programming forums, part of the General Programming Boards category; it is possible to send bash commands into a c application right? for example if i wanted to do a ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    10

    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 http://example.com" inside a c application how would this be done?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,755
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

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

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
    	popen("wget http://google.com", "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
    a_capitalist_story
    Join Date
    Dec 2007
    Posts
    2,652
    Use the full path to wget? Run "which wget" in the console to find it.

  5. #5
    Registered User
    Join Date
    Mar 2011
    Posts
    10
    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 06: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, 12:02 PM
  2. Writing to other files
    By Liz320 in forum C Programming
    Replies: 19
    Last Post: 05-26-2009, 07: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, 02:33 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21