Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    quick C question using execl()

    Hi everyone.
    Im currently testing an example given to me that uses the C execl() function (the function looks up for a file composed of a command, eg win32 files, executes them and then terminates). Im getting no probs in terms of syntax structure, but the program does not appear to be terminating the command. The code is shown below

    #include <stdio.h>
    #include <process.h>
    int main()
    {
    printf("testing connection:\n");
    execl("c:\windows\system32\ping.dos","ping","localhost",0);
    return 0;
    }

  • #2
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    execl does not return to the calling process.
    Omnis mico antequam dominus Spookster!

  • #3
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Mhtml
    execl does not return to the calling process.
    Sorry, but what my actual concern is why isn't the command executing before it terminates ?

  • #4
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    Oh right I see, well check to see what it returns. If you get anything returned there is a problem with the command.

    Oh, lol I see it ... What is "ping.dos" ?? now call me silly but I thought that ping, along with most programs on windows used .exe ..
    Omnis mico antequam dominus Spookster!

  • #5
    New to the CF scene
    Join Date
    Jan 2004
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Originally posted by Mhtml
    Oh right I see, well check to see what it returns. If you get anything returned there is a problem with the command.

    Oh, lol I see it ... What is "ping.dos" ?? now call me silly but I thought that ping, along with most programs on windows used .exe ..
    thanks for picking that up, but *if* i am right, u don't have to explicitly declare the file extension. I tried it without the any extension and still had no luck.

    Also, another quick question, what should happen is that the msdos command is quickly executed and then it goes back to the source code screen?

    Thanks for all your help so far though.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •