proc getDistributionName {} {
set OSName ""
if {[file exists "/etc/os-release"]==1} {
set release [open "/etc/os-release" r]
while {1} {
if {[chan gets $release line] > 0} {
set info [split $line "="]
if {[string compare [lindex $info 0] "NAME"]==0} {
set OSName [lindex $info 1]
break;
}
} else {
if {[chan eof $release]} {
break;
} else {
puts "Something is wrong."
break;
}
}
}
chan close $release
} else {
return -code error "/etc/os-release not exist!!!"
}
return $OSName
}
參考資料:
os-release — Operating system identification
沒有留言:
張貼留言