【发布时间】:2020-07-15 21:55:19
【问题描述】:
我在 Bash 中编写了一个脚本,我想用 gnuplot 绘制数据。当我用 gnuplot 调用这个脚本时,错误信息是:
"sar-P-gnuplot-script", line 3: Column number or datablock line expected
您在执行此操作时似乎无法定义任何变量:
gnuplot "*my_script*"
代码/脚本:
#!/bin/bash
current_time=$(date +"%T")
new_time=$(date -d "$current_time today + 10 seconds" +'%H:%M:%S')
set xdata time
set timefmt "%H:%M:%S"
set xrange ["$current_time":"$new_time"]
set format x "%H:%M:%S"
plot "sar-P-plots11" using 1:2
pause -1 "Hit any key to continue"
Bash 脚本:
#!/bin/bash
# sar-P-script : script that will take sar-P and plot it
current_t=$(date +"%T")
# input the sar-P results into a file
sar -P 1 1 11 > sar-P-1-1-11
new_t=$(date +"%T")
# remove the first line (you don't need it)
sed -i '/dennis/d' sar-P-1-1-11
# makes the spaces commas, and then squeezes repeating commas
tr -s ' ' ',' < sar-P-1-1-11 > new-sar-P-1-1-11
# cuts the first field into a new file (the times)
cut -d ',' -f 1 new-sar-P-1-1-11 > sar-times11
# cuts the last field into a new file (percentages)
cut -d ',' -f 8 new-sar-P-1-1-11 > sar-idle11
# creates an x and y table
paste sar-times11 sar-idle11 > sar-P-plots11
# cuts away anything that we don't need (headers)
sed -i '/Average/d' sar-P-plots11
sed -i '/idle/d' sar-P-plots11
./sar-P-gnuplot-script
【问题讨论】:
-
感谢编辑