#!/mod/bin/jimsh

package require cgi
source /mod/webif/lib/setup
require system.class

cgi_input
#cgi_dump

set diag [cgi_get diag general]

httpheader "text/plain"

if {[system modversion 1] < 113} {
	puts ">>> Diagnostics only available with customised firmware 1.13 or above."
	exit
}

puts ">>> Beginning diagnostic $diag\r\n"

set bcmd "|/bin/diag $diag"
set fd [open $bcmd r]
while {[gets $fd line] >= 0} {
	puts "$line"
}
close $fd
puts "\r\n"
puts ">>> Ending diagnostic $diag\r\n"

