[TV] I played an hour with a server and a cgi tcl script to create a Jukebox accesable from the web (A Nokia Communicator with always on internet or some portable computer) to have a big list of songs on a page to click-and-play. The server where this image is on, too: [http://82.171.148.176/Wiki/jukebox.png] has a lot of music files stored on it (about 2k songs from legally rented CDs, and never shared with anyone, and it stays that way) and it would be handy to sit somewhere (like in the garden) and click a song toplay it on my big audio system, isn't it? So I made these two Tcl scripts, one in the /var/www/cgi directory called mus.tcl: #!/bin/sh # \ exec tclsh "$0" "$@" # puts stdout "Content-type: text/html\n" puts stdout "" puts stdout "This page lets you play a music file on my server." puts stdout "
" flush stdout if {[catch {set s [socket localhost 4328]}] != 0} { puts stdout "The jukebox is inactive!" puts stdout "
www.theover.org"
puts stdout ""
flush stdout
exit
}
set n -1
if {[string compare $env(QUERY_STRING) ""] != 0} {
set n [lindex [split $env(QUERY_STRING) \#] 0]
puts $s $n
flush $s
} {
puts $s -1
flush $s
}
set j 0
foreach i [glob /somepath/Music/*.wav] {
if {$n != $j} {
puts stdout "$j [string range [lindex [split $i .] 0] [string length "/somepath/Music/"] end]
"
} {
puts stdout " $j [string range [lindex [split $i .] 0] [string length "/somepath/Music/"] end]
"
}
flush stdout
incr j
}
puts stdout "done"
puts stdout "
www.theover.org" puts stdout "