a program that opens the browser

This is a discussion on a program that opens the browser within the C Programming forums, part of the General Programming Boards category; hello people, i want to write a program in c, that when i run it, it should open the browser ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    39

    Post a program that opens the browser

    hello people,
    i want to write a program in c, that when i run it, it should open the browser ( firefox , since I'm using Linux) and goes to a given URL automatically, like:
    http://localhost:8080/something.html
    this URL should be hard coded.
    how can I do this? a sample code or example would be really nice
    thanking you in advance

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Look into the spawnvpe function (passing P_NOWAIT as the first parameter).

  3. #3
    Registered User
    Join Date
    Jan 2009
    Posts
    39
    can u show me with an example code?

  4. #4
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Can you read documentation?

  5. #5
    Registered User ssharish2005's Avatar
    Join Date
    Sep 2005
    Location
    Cambridge, UK
    Posts
    1,682
    Dint really wanted to post the code. But i've been good to you today :-/

    Code:
    #include <process.h>
    
    int main()
    {
        int pid;
        
        if( ( pid = spawnvp( P_NOWAIT, "mozilla", "www.google.co.uk" ) ) != 0 )
            printf("New process created!\n");
        else
            printf("Error: spawnvp failed.\n");
        
        return 0;
    }
    ~ssharish
    Life is like riding a bicycle. To keep your balance you must keep moving - Einstein

  6. #6
    Registered User
    Join Date
    Jan 2009
    Posts
    39
    thanks, but do i need to compile it agains any library? cuz this is my output when i compile it with this command:

    Code:
     #:~/Desktop/ex/bt/http$ gcc url.c -o url
    the output:
    Code:
    url.c:1:21: error: process.h: No such file or directory
    url.c: In function ‘main’:
    url.c:6: error: ‘P_NOWAIT’ undeclared (first use in this function)
    url.c:6: error: (Each undeclared identifier is reported only once
    url.c:6: error: for each function it appears in.)
    url.c:7: warning: incompatible implicit declaration of built-in function ‘printf’

  7. #7
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    spawnvp is depreciated on *nix. Read the GNU manual on execvp() instead.

    execvp() example code
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  8. #8
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    Try #include <unistd.h> and execvp() or fork().
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  9. #9
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    Quote Originally Posted by MK27 View Post
    spawnvp is depreciated on *nix. Read the GNU manual on execvp() instead.

    execvp() example code
    Hmm. I had always assumed they were standard functions. I guess not, though.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. How do you read gzip output from 'C' program?
    By brett in forum C Programming
    Replies: 5
    Last Post: 03-12-2006, 11:01 PM
  2. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 06:49 PM
  3. I need some help with my program please.
    By agentxx04 in forum C Programming
    Replies: 9
    Last Post: 09-26-2004, 07:51 AM
  4. Unknown Memory Leak in Init() Function
    By CodeHacker in forum Windows Programming
    Replies: 3
    Last Post: 07-09-2004, 09:54 AM
  5. Replies: 2
    Last Post: 05-10-2002, 04:16 PM

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