Re: lug-bg: "C" wapros
- Subject: Re: lug-bg: "C" wapros
- From: vsulov@xxxxxxxxx (Vladimir Sulov)
- Date: Tue, 16 May 2000 22:27:36 +0300
----- Original Message -----
From: "Georgi Chorbadzhiyski" <gf@xxxxxxxxxx>
To: <lug-bg@xxxxxxxxxxxxxxxxxx>
Sent: Tuesday, May 16, 2000 7:01 PM
Subject: lug-bg: "C" wapros
>
> 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);
Kakvo imash v exec_buf, kogato vikash?
Bi sledvalo da imash masiv ot char* - parametri, kato posledniyat da e NULL,
a ako ne iskash parametri - oshte parviyat da e NULL, no ne i exec_buf da e
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.
>
> ==================================================================
> 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
==================================================================
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
|