の実際の値に配列を変更するためには、この行に文字列$ Fを挿入し、HTMLファイルを開く12行を削除し、必要がある私のbashのファイル温度センサ。しかし、ベンチを実行すると、何も編集されません。私のbashは、私のファイルを編集することはできません
temp.sh
#!/bin/bash
f="myArray_a = ["
for ((i=0 ; 12 - $i ; i++))
do
x=$(cat /sys/bus/w1/devices/28-0000075292ed/w1_slave | grep "t=" | awk -F "t=" '{print $2/1000}')
if [ $i -eq 11 ]
then
x=$(printf %.3f] $x)
f="$f $x"
sed '12 d' index.html
sed -i -e '12i'$f' '$12'\' index.html
else
x=$(printf %.3f, $x)
f="$f $x"
fi
done | column
index.htmlを
<!DOCTYPE HTML>
<html>
\t <head>
\t \t <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
\t \t <META HTTP-EQUIV="Refresh" CONTENT="10">
\t \t <title> Temperature values</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
\t \t <style type="text/css">
${demo.css}
</style>
\t <script type="text/javascript">
myArray_a
myArray_a
myArray_a
myArray_a
var myArray_a = [1, 2, 3, 4, 0, 5, 0, 0, 0, 0, 0, 0, 1];
$(function() {
$(document).ready(function() {
Highcharts.setOptions({
global: {
useUTC: false
}
});
$('#container').highcharts({
chart: {
type: 'spline',
animation: Highcharts.svg, // don't animate in old IE
marginRight: 10,
events: {
}
},
title: {
text: 'Live sensor data'
},
xAxis: {
type: 'datetime',
tickPixelInterval: 150
},
yAxis: {
title: {
text: 'Value'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
},
legend: {
enabled: false
},
exporting: {
enabled: false
},
series: [{
name: 'sensor data',
data: (function() {
// generate an array of random data
var data = [],
time = (new Date()).getTime(),
i;
for (i = 0; i <= 12; i += 1) {
data.push({
x: time + i * 1000,
y: myArray_a[i]
});
}
return data;
}())
}]
});
});
});
\t \t </script>
\t </head>
\t <body>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
\t </body>
</html>
あなたは 'html'ファイルを直接変更することができますか?私はいつも '.txt'ファイルを使いました。 – keras
私はすべての例を.txtで見ました。私は任意の拡張子を使用できると思っていました。私の問題を解決するための他の解決策はありますか? – user5996908
'html'コードを' txt'ファイルにコピーして修正しますが、それを行うコマンドは分かりません。 – keras