Mail Archives: djgpp/1998/03/30/21:27:55
At 07:14 PM 3/30/98 -0500, John M. Aldrich wrote:
>ricki lee king wrote:
>>
>> this runs ping.exe but feeds it garbage for an arguement.
>> pls tell me how to fix it.
>>
>> #include <unistd.h>
>> main()
>> {
>> execl("c:/windows/ping","www.iquest.net");
>> }
>>
>> thanks
>
>You're using execl() incorrectly. According to the libc docs, it's
>prototyped as follows:
>
> int execl(const char *path, const char *argv0, ...);
>
>If you use this syntax, then you're making two mistakes:
>
>1) You are passing "www.iquest.net" as argv[0], which is the name of the
>program, instead of argv[1], which is the first argument.
>
>2) You are not terminating the variable-length argument list with a
>NULL, so execl() has no idea when to stop sending arguments.
>
>You are also forgetting that execl() might return unsuccessfully, in
>which case you should trap the error and print a suitable message.
>
>Correct code:
>
>#include <stdio.h>
>#include <unistd.h>
>int main( void )
>{
> if ( execl( "c:/windows/ping", "c:/windows/ping", "www.iquest.net",
>0 ) != 0 )
> perror( "c:/windows/ping" );
> return 1;
>}
>
>I have compiled this code and it works correctly on my system.
>
>BTW, the following works just as well:
>
> system( "c:/windows/ping www.iquest.net" );
here is my final isp pinger.
it pings my isp about every 12 minutes on my 486.
i was daunted by all the time functions so i used
a for loop to kill time. i know its ugly.
this is my first practical program but i am sure
it already exists. i will learn time functions later.
#include <stdlib.h>
main()
{
long double n;
system("c:/windows/ping www.iquest.net");
beginsh:
for (n=1; n<999999999.01;n++)
{
}
system("c:/windows/ping www.iquest.net");
goto beginsh;
}
bye
- Raw text -