[ILUG] bash: nohup can't see a function
blf at blf.utvinternet.ie
Fri Jun 3 05:13:31 IST 2005
| Date: Thu, 2 Jun 2005 12:03:51 +0200
| From: "bryan ( admin at revoltingdigits.com)" <revoltingdigits at gmail.com>
| [ ... ] the email contains the following .,.....
| /usr/bin/nohup: line 79: exec: restartoraclegui: not found
nohup(1) exec(3)s things.
you cannot exec a function embedded in a script.
(you _could_ exec a function separated into its
own file, but such exec'ing is pointless.)
| Perhaps I am trying a completely wrong approach here,
| i also considered using this line
| then ( restartoraclegui | mail admin\@revoltingdigits.com -s "oracle gui restart" 2>&1 )
accomplishes nothing but adding confusion.
change the line to (I assume you have the args to
mail(1) in the correct order, albeit it does not
look quite right me?):
restartoraclegui 2>&1 | mail admin\@... -s "..."
(i.e., move the `2>&1' to a useful place and get
rid of the now-pointless backgrounding (`&')),
and then do the `nohup' and backgrounding when
you invoke the script:
nohup SCRIPT &
as a reminder, add a comment to that effect at
the top of the script. (you _could_ also detect
by a proxy test that this may not have been done
and issue an message; see test(1) `-t' operator.)
the above has the additional advantage the `mail' is
also `nohup'ed, so if it does happen to be SIGHUPed
you should still get e-mail. in the original,
whilst the Oracle stuff might complete even if
there is a SIGHUP (this is not clear, see below),
there would be no e-mail --- the `mail' would have
because the `mail' would have been killed, it is
possible the Oracle stuff would not complete:
_if_ that stuff did any output to stdout (or stderr,
after you fix the redirection) after the SIGHUP and
death of `mail', they would get a "Broken pipe"
(SIGPIPE/EPIPE) and _also_ die.
Experienced (20+ yrs) kernel/software Eng: | Brian Foster Montpellier,
• Unix, embedded, &tc; • Linux; • doc; | blf at utvinternet.ie FRANCE
• IDL, automated testing, process, &tc. | Stop E$$o (ExxonMobile)!
Résumé (CV) http://www.blf.utvinternet.ie | http://www.stopesso.com
More information about the ILUG