Asi pred mesicem jsem resil presne ten samy problem jako autor clanku. Nabizim alternativni skript pro ty, ktere (tak jako mne) nebavi hrabat se v cronu:
#!/bin/sh
# The next line restarts with tclsh.\
exec tclsh "$0" ${1+"$@"}
# station definitions
set station(praha) {http://icecast5.play.cz:8000/cro2-128.mp3}
set station(vltava) {http://icecast5.play.cz:8000/cro3-128.mp3}
set station(wave) {http://icecast5.play.cz:8000/crowave-128.mp3}
set station(radio1) {http://netshow.play.cz:8000/radio1.mp3}
set station(humor) {http://mp3stream4.abradio.cz:8000/humor128.mp3}
set destination {~/Downloads/}
set downloadProgram {/usr/bin/streamripper}
set tmpfile {/tmp/.atjob}
# input parameters
if { $argc != 3 } {
puts "The radio.tcl script requires the following input parameters:"
puts " - radio station: \[ [array names station] \]"
puts " - start time: \[ examples: Mon12:30 or 18:45 \]"
puts " - duration: \[ example: 0:30 \]"
puts "Example: radio.tcl praha Mon20:00 1:30"
exit
} else {
set inpStation [lindex $argv 0]
set inpStartTime [lindex $argv 1]
set inpDuration [lindex $argv 2]
}
# create atjob file
if { [catch {open $tmpfile w} atJobfileId] } {
puts "Could not open $tmpfile for writing\n"
exit
}
# create destination directory
if [file isdirectory $destination] {
puts "INFO: Directory $destination already exists"
} else {
file mkdir $destination
puts "INFO: Creating directory $destination"
}
# get current date
set currDay [clock format [clock seconds] -format %a]
# calculate start time
if [regexp {^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)*([0-2]*[0-9]):([0-5][0-9])$} $inpStartTime {} dStart hStart mStart] {
puts "INFO: Start time: $dStart ${hStart}:${mStart}"
} else {
puts "ERROR: Start time format not recognized ( $inpStartTime )"
exit
}
# calculate length
if [regexp {^([0-3]*[0-9]):([0-5][0-9])$} $inpDuration {} h m] {
puts "INFO: Duration: ${h}:${m} "
set length [expr ($m + ($h * 60)) * 60]
puts "INFO: Duration: ${length} \[seconds\]"
} else {
puts "ERROR: Duration format not recognized ( $inpDuration )"
exit
}
# main loop
foreach i [array names station] {
if {$i == $inpStation} {
puts "INFO: Found station $i ( $station($i) )"
puts "INFO: writing $downloadProgram $station($i) -d $destination -D %d_%S -l $length to $tmpfile"
puts $atJobfileId "$downloadProgram $station($i) -d $destination -D %d_%S -l $length"
puts "INFO: running: at ${hStart}:${mStart} $dStart < $tmpfile"
close $atJobfileId
puts "INFO: closing ${destination}/atjob"
set runcmd [list exec at "${hStart}:${mStart}" $dStart \< "$tmpfile"]
if {[catch $runcmd res]} {
puts "INFO: $runcmd: $res"
}
exit
}
}
puts "ERROR: Station name not recognized ( $inpStation )"
Zdravím, moc pěkný skriptík, je vidět, že si skriptování užíváte.Líbí se mi, jak jste vyřešil seznam oblíbených rádií a spouštění přes parametr. Řeší ale spuštění 1x v určený čas - to je dobré pro nahrání určitého pořadu a je samozřejmě zbytečné to dávat do CRONU. Já si pravidelným spouštěním naplňuji archiv o nové skladby pro offline poslech. Děkuji za inspiraci.