Gentoo Archives: gentoo-user

From: Thomas Tuttle <gentoo@×××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] debugging init scripts
Date: Thu, 12 Jul 2007 17:12:22
Message-Id: 1184260003.10327.1199851397@webmail.messagingengine.com
In Reply to: Re: [gentoo-user] debugging init scripts by Uwe Thiem
1 On Thu, 12 Jul 2007 17:15:40 +0100, "Uwe Thiem" <uwix@××××.na> said:
2 > On 12 July 2007, Frank Wilson wrote:
3 > > I'm trying to debug an init script / daemon I'm trying to run. I can't
4 > > seem to print the debug output to print to a file. For example I
5 > > enter:
6 > >
7 > > /etc/init.d/apache2 restart --debug >> /root/apache2.debug
8 > >
9 > > or
10 > >
11 > > /etc/init.d/apache2 restart --debug > /root/apache2.debug
12 > >
13 > > but I get none of the debug output. Also less insists that
14 > > /root/apache2.debug is a binary file... not sure why.
15 >
16 > First of all, you should do something like "/etc/init.d/apache2
17 > restart --debug > /root/apache2.debug 2>&1" to catch both, standard and
18 > error
19 > output.
20
21 Yes, I agree.
22
23 > Still, this won't work in your case. The output you usually see on
24 > screen, is
25 > *not* generated by the script (or the executing shell) but by the
26 > commands
27 > used in the script.
28
29 If it's generated by a command used in the script, it will be sent to
30 the file. stdout is stdout, and if it's redirected to a file in the
31 shell running the script, it will go to the same place in any commands
32 run by that shell, unless they reopen it to another file.
33
34 > So keep a backup of the original script, then dive into it with your
35 > favourite
36 > editor and append ">> /root/apache2.debug 2>&1" to all relevant commands.
37
38 I don't think you need to.
39
40 At worst, wrap the command in parentheses to run it in a subshell, like
41 this:
42
43 ( /etc/init.d/apache2 restart --debug ) > /root/apache2.debug 2>&1
44
45 But you shouldn't need that.
46
47 Just to get this straight... you're trying to capture the output of the
48 initscript, not of Apache itself, right?
49
50 And as for less thinking it's a binary file, that's because the Gentoo
51 initscripts change the text color using escape codes, which are
52 considered binary by less. (Specifically, the escape character, ASCII
53 27, is probably considered binary.)
54
55 Hope this helps,
56
57 Thomas Tuttle
58 --
59 Thomas Tuttle - ttuttle@×××××××.net - http://www.ttuttle.net/
60
61 --
62 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] debugging init scripts Iain Buchanan <iaindb@××××××××××××.au>