home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / unix / programm / 4394 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  1.5 KB

  1. Path: sparky!uunet!olivea!news.bbn.com!usc!sdd.hp.com!hplabs!ucbvax!IMPAB.SE!mwk
  2. From: mwk@IMPAB.SE (Maria Waldemark)
  3. Newsgroups: comp.unix.programmer
  4. Subject: Exec a shell
  5. Message-ID: <m0mLVRr-00015oC@jocke.impab.se>
  6. Date: 21 Aug 92 17:38:27 GMT
  7. Sender: usenet@ucbvax.BERKELEY.EDU
  8. Lines: 52
  9.  
  10.  
  11.     Hi,
  12.  
  13.     I want to run following command from a C-program by an exec call:
  14.  
  15.     >x.cmd param1 param2 ...
  16.  
  17.     Before x.cmd is executed I want to run the login shell.
  18.  
  19.     Everything works perfectly if I do as described below but it 
  20.     only works from one user.
  21.  
  22.     --------------------------------------------------------------------
  23.  
  24.     freopen("/dev/null", "r", stdin);
  25.     freopen("/user/mwk/log", "a", stdout);
  26.  
  27.     arg[0] = "-";
  28.     arg[1] = "-c";
  29.     arg[2] = "/user/mwk/x.cmd param1 param2";
  30.     arg[3] = NULL;
  31.  
  32.  
  33.     ret = execve("/usr/bin/sh", arg, env);
  34.  
  35.  
  36.     --------------------------------------------------------------------
  37.  
  38.      mwk 29596     1  0 10:36:34 ?        0:00 - -c /user/mwk/x.cmd parma1 param2 
  39.      mwk 29597 29596  0 10:36:34 ?        0:00 - -c /user/mwk/x.cmd param1 parma2 
  40.  
  41.     --------------------------------------------------------------------
  42.  
  43.  
  44.  
  45.     I want to do the execve call from a daemon, which has no controlling
  46.     terminal. The daemon never runs the script !!!
  47.     In the logfile /user/mwk/log there is only some debug prints from
  48.     the daemon.
  49.  
  50.     
  51.     Can someone help me please ?
  52.  
  53.     /Maria
  54.  
  55.  
  56. -- 
  57.  
  58.   Maria Waldemark                   Tel: +46-8-6507525  Fax: +46-8-6502870
  59.   IM Program AB                        Email : mwk@impab.se
  60.   Fleminggatan 56
  61. S-112 45 Stockholm,  Sweden
  62.