I am using netcat to get a series of points which I would like to plot with gnuplot. However, I am having trouble passing the data to gnuplot without writing it to a file first.
In the simplest case, I want to plot a 3-point line that I've defined in a variable first as follows:
#!/bin/bash
DATA="10
12
15"
echo "$DATA"
# Data looks good in terminal (single vertical column of numbers 10, 12, 15)
# However, the following step doesn't work:
gnuplot -persist <<-EOFMarker
plot $DATA w lines
EOFMarker
The actual use case is to get data from a networked Rigol oscilloscope and show it in a plot. Here is the full script so far:
#!/bin/bash
SERVER=192.168.0.12
PORT=5555
RIGOLDATA="$(echo ":TRAC:DATA? TRACE1" | netcat -q1 $SERVER $PORT | cut -c 13- | tr ',' '\n' | tr -d [:blank:])"
echo "$RIGOLDATA"
# RigolData looks good in terminal (single vertical column of numbers).
# However, the following does not work:
gnuplot -persist <<-EOFMarker
plot $RIGOLDATA w lines
EOFMarker
I can get the desired result by passing the data into a temp file first as follows, but I am trying to avoid the use of a temp file:
#!/bin/bash
SERVER=192.168.0.12
PORT=5555
RIGOLDATA="$(echo ":TRAC:DATA? TRACE1" | netcat -q1 $SERVER $PORT | cut -c 13- | tr ',' '\n' | tr -d [:blank:])"
echo "$RIGOLDATA" > tempfile.csv
gnuplot -persist <<-EOFMarker
plot "tempfile.csv" w lines
EOFMarker
plot $DATA w linesexpands to, and does it look like the correct command to give?cat <<EOF[newline]*[newline]EOF[newline]just prints*, it's globbed)