I am trying to capture the stdout when I print on shell. I get output like this:
************* STARTING healthmonitor ***********************
Aug 28, 2014 5:17:58 AM org.rzo.yajsw.os.posix.PosixService getPid
INFO: wrapper pid file: /var/run/wrapper.healthmonitor.pid
Aug 28, 2014 5:17:58 AM org.rzo.yajsw.os.posix.PosixService startProcess
INFO: calling "/usr/bin/java" "-Dwrapper.pidfile=/va/run/wrapper.healthmonitor.pid"
Aug 28, 2014 5:17:58 AM org.rzo.yajsw.os.posix.PosixService getPid
INFO: wrapper pid file: /var/run/wrapper.healthmonitor.pid
Aug 28, 2014 5:18:00 AM org.rzo.yajsw.os.posix.PosixService getPid
INFO: wrapper pid file: /var/run/wrapper.healthmonitor.pid
However, when I use the same output to print on a webpage, the format gets jumbled like this:
********* STARTING healthmonitor ******************* Aug 28, 2014 4:48:23 AM org.rzo.yajsw.os.posix.PosixService getPid INFO: wrapper pid file: /var/run/wrapper.healthmonitor.pid Aug 28, 2014 4:48:23 AM org.rzo.yajsw.os.posix.PosixService startProcess INFO: calling "/usr/bin/java" "-Dwrapper.pidfile=/var/run/wrapper.healthmonitor.pid" "-Dwrapper.service=true" "-Dwrapper.visible=false" "-Djna_tmpdir=/app/sterling/jsw/healthmonitor/bin/../tmp" "-jar" "/app/sterling/jsw/healthmonitor/wrapper.jar" "-c" "/app/sterling/jsw/healthmonitor/conf/wrapper.conf" Aug 28, 2014 4:48:23 AM org.rzo.yajsw.os.posix.PosixService getPid INFO:
The python script which prints this is called in a java script file using cgi python way of calling. And in the python script, this is how its printed.
import cgi, cgitb
print("Content-type: text/html\n\n")
print """
<html><head></head>
<body>
<br>
"""
print nova.servers.get_console_output(VMID)
print """
</body></html>
"""
The "print nova.servers.get_console_output(VMID)" is the one that produces the console output.
Thanks for any help you can offer.
nova.servers.get_console_output(VMID)in a<p><pre>? I don't believe newlines are honored in a<p>, but I know for sure they are in a<pre>. An alternative would beprint nova.servers.get_console_output(VMID).replace("\n", "<br>")<pre>