Re: lug-bg: "C" wapros
- Subject: Re: lug-bg: "C" wapros
- From: luben@xxxxxxxxxxxxx (luben karavelov)
- Date: Tue, 16 May 2000 23:56:57 +0300
Georgi Chorbadzhiyski wrote:
>
> Ako mozhe niakoi po svetnat da pomogne. Imam slednata programa
>
> #
> # funkciikata e orezana versia ot pppd
> #
> int run_program(prog, args, must_exist, done, arg)
> char *prog;
> char **args;
> int must_exist;
> void (*done) __P((void *));
> void *arg;
> {
> int pid;
>
> pid = fork();
> if (pid == -1) {
> log(L_ERR, "Failed to create child process for %s", prog);
> return -1;
> }
> if (pid == 0) {
> /* run the program */
> execvp(prog, args);
> if (must_exist || errno != ENOENT) {
> /* have to reopen the log, there's nowhere else
> for the message to go. */
> log(L_ERR, "Can't execute: %s error: %u", prog, errno);
> }
> _exit(-1);
> }
> return pid;
> }
>
> wikam si funkciikata taka:
>
> run_program("/usr/local/my_script", exec_buf, 0, NULL, NULL);
>
> /usr/local/my_script sadyrzha:
>
> #!/bin/sh
> echo raboti! >> /tmp/proba
>
> Wsichko ok obache, kato go wikna tova run_program i waw log-a
> mi pishe:
>
> can't execute: /usr/local/my_script error: 14
>
> kogato skript-a ne e izpalnim msg-to e:
>
> can't execute: /usr/local/my_script error: 13
>
> Kakvo oznachavat tezi i greshki i kakvo sam obyrkal ??
>
> Georgi Chorbadzhiyski
> System Administrator
> Cybercom Ltd.
triabva da izpulniavash ne "my_script", a "/bin/sh
my_script". exec-functiiite ti
load-vat image, koito da izpulnat, kakavto yavno ne e tvyoya
script. Na purvia red
directivata !/bin/sh e directiva kym shell-a, akavto
niamash, kogato izpulniavash
exec().
Luben
==================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
Otpiswaneto RABOTI !!! : Majordomo@xxxxxxxxxxxxxxxxxx UNSUBSCRIBE LUG-BG
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora
|