Re: Calling ssh from C-Program with execvp
- From: Sensei <senseiwa@apple's mail.com>
- Date: Mon, 22 Jan 2007 09:10:15 +0100
On 2007-01-21 19:28:38 +0100, "Richard E. Silverman" <res@xxxxxxxx> said:
---------------------------------------------------------------
#include <stddef.h>
#include <sys/types.h>
#include <sys/wait.h>
main () {
int status;
char *argv[] = {"ssh","remote_host","echo","foo",NULL};
if (fork()) {
wait(&status);
} else {
execvp("/usr/bin/ssh", argv);
}
}
---------------------------------------------------------------
Just a slight modification. The main function must return an int according to the standard, use:
int main(int argc, char* argv[])
or
int main(void)
And don't forget the return statement. Just my 2 cents to avoid undefined behaviors :)
--
Sensei <senseiwa@Apple's mail>
Research (n.): a discovery already published by a chinese guy one month
before you, copying a russian who did it in the 60s.
.
- References:
- Re: Calling ssh from C-Program with execvp
- From: Richard E. Silverman
- Re: Calling ssh from C-Program with execvp
- Prev by Date: Re: Calling ssh from C-Program with execvp
- Next by Date: Re: Calling ssh from C-Program with execvp
- Previous by thread: Re: Calling ssh from C-Program with execvp
- Next by thread: Re: Calling ssh from C-Program with execvp
- Index(es):
Relevant Pages
|
|