18 Jun 2011 15:15
backticks: how to put process into background?
Christian Ebert <blacktrash <at> gmx.net>
2011-06-18 13:15:40 GMT
2011-06-18 13:15:40 GMT
Hi,
Is there a way to force a process inside backticks into
background? `&` seems to have no effect.
Example: I'm trying to migrate a filter to display (X-)Faces -
used as display filter in mutt - from procmail to maildrop.
Everything works except putting the viewer in the background:
# customize X11 viewer (has to accept stdin)
VIEWER="/sw/bin/xv -geometry 100x100 -wait 3 -"
# adjust paths of required programs for speed
AWK="/usr/bin/awk"
REFORMAIL="/usr/local/bin/reformail"
OPENSSL="/usr/bin/openssl"
PRINTF="/usr/bin/printf"
UNCOMPFACE="/sw/bin/uncompface"
# check if $DISPLAY is non-empty
if ("$DISPLAY")
{
if (/^Face:\s+(.{16,})/)
{
# work around broken headers
# (re)create lines of width 79, removing all spaces
# delete potentially appended X-Face (Claws-Mail)
`$PRINTF '%s\n' $MATCH1 | $AWK '{ if ($1 == "X-Face:") exit; OFS = ""; $1 = $1; line = $0; do { print
substr(line, 0, 79); line = substr(line, 80); } while (length(line)); }' | $OPENSSL base64 -d | $VIEWER &`
xfilter "$REFORMAIL -I'Face:'"
(Continue reading)



> The argument to nohup is a command to execute. "(…)" is not a command,
> it is a shell pipeline construct. This is parsed and interpreted by
> the shell.
>
> [mrsam <at> octopus maildrop]$ which nohup
> /usr/bin/nohup
>
> nohup is a standalone command. Its first argument is the command to
> execute with SIGHUP disabled. The remaining arguments are passed
> through as the arguments to the command.
>
> nohup does not incorporate an entire shell interpreter and parser
> inside of itself. As such, shell constructs, such as (pipeline) do not
> work when you pass it to nohup.
>
> Your backtick command should probably be:
>
> `nohup /bin/sh -c "command &"`
Yes, I forgot to mention that I also tried:
`nohup /bin/sh -c '$PRINTF "%s\n" $MATCH1 | $UNCOMPFACE -X | $VIEWER &'`
which behaves exactly like without nohup:


RSS Feed