[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Hotplug scripts not working... xen/ia64 domU stopped working



On Fri, 2 Dec 2005, Ewan Mellor wrote:

> On Thu, Dec 01, 2005 at 06:53:54PM -0600, Adam Heath wrote:
>
> > On Thu, 1 Dec 2005, Ewan Mellor wrote:
> >
> > > Doing that writes to stderr, which unfortunately is going straight down
> > > /dev/null, because this is being run by the kernel's hotplug 
> > > infrastruture.
> >
> > exec 2>> /tmp/shell-debug.log
>
> Now _that's_ useful!

One of my standard tricks for debugging shells run automatically by some other
system, is to add the following lines at the top:

==
exec 2>> /tmp/shell-debug.log
echo $$
date
==

It'd be nice if one could change stderr to go to a pipe, in standard posix
shell.  One *can* do that in more advanced shells(zsh and bash, for example).

The bash syntax for the above is:

==
mypid=$$
set -x
exec 2> >(perl -e '$|=1;while(<STDIN>){s,^,\Q$ARGV[0]\E(\Q$ARGV[1]\E): 
,;print}' -- ProgramName $mypid | tee /tmp/shell-debug.log)
date
echo $$
echo test
echo foo 1>&2
==

Gives this in /tmp/shell-debug.log, in addition to still sending to stderr(one
could send things to syslog as well, by modifying the above):

==

==
adam@gradall:~/code/dpkg/arch$ bash /tmp/foo.sh
Thu Dec  1 20:12:44 CST 2005
21787
test
adam@gradall:~/code/dpkg/arch$ ProgramName(21787): + date
ProgramName(21787): + echo 21787
ProgramName(21787): + echo test
ProgramName(21787): + echo foo
ProgramName(21787): foo

adam@gradall:~/code/dpkg/arch$ cat /tmp/shell-debug.log
ProgramName(21787): + date
ProgramName(21787): + echo 21787
ProgramName(21787): + echo test
ProgramName(21787): + echo foo
ProgramName(21787): foo
==

The only downside is the delayed printing of the backgrounded processing.

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.