Date: Fri, 18 Oct 2002 13:58:08 -0700 From: James Long <list@museum.rain.com> To: freebsd-questions@freebsd.org Subject: How to fork from within .forward? Message-ID: <20021018135808.A2489@ns.museum.rain.com>
next in thread | raw e-mail | index | archive | help
I'm trying to set up an email-daemon which accepts info via email, acts on it, and returns a result. I have a dummy user set with a .forward file: "|./sample.sh $PPID" sample.sh parses the email text and creates a shell script. I'm new at this sort of thing, so my first uncertainty is the run-time environment of sample.sh. From looking at the output of "set >foo" from within sample.sh, I see variables like AGENT=sendmail etc., but otherwise a rather sparse environment. But nonetheless, sample.sh works and does its thing quickly. The shell script that sample.sh creates (child.sh) now needs to run. I want to run it under the userid to which the email was sent (the owner of the .forward file, duh). And in the background, so that the sendmail delivery process can complete and terminate. After some googling, man paging and trial and error (a 1:1 ratio in fact, of trial vs. error!) I have not been able to divine the proper command line to spawn a full-featured shell (one with valid PATH and HOME variables, etc.) which will allow the background script to execute. Unsuccessfull candidates have been: /usr/bin/su username -c ". child.sh" & and with 700 perms on child.sh I tried: /bin/sh ./child.sh & and /bin/sh - ./child.sh & without any luck. I also tried putting ". /etc/profile" near the top of child.sh. child.sh runs fine when I log in as username and run it manually via "./child.sh &". How can I spawn it from within the .forward file delivery process (sample.sh) that will spawn it in such a way that it inherits a login-style environment? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20021018135808.A2489>