Skip to content
Advertisement

Passing a Command as a Variable to another Program?

I’m creating an interactive script that allows me to plot specific parts of a data file using Gnuplot. These files contain multiple channels of instrumentation data and I’d like to plot specified channels together on the plot. At the moment I can only plot each channel independently with a script.

JavaScript

This is the code that plots each channel independently. To plot them together I need the the plot line to look like this

JavaScript

My question is how, if possible, could I have a for loop outside gnuplot that appends each column command (“$FILE” using $xcolumn:$ycolumn1 lt with lines t ” “) to a variable, and then that variable gets passed to the plot command inside Gnuplot?

I was thinking about using expect but I can’t figure out a way to implement that in the way I’m trying to automate this script.

Advertisement

Answer

Probably the most straightforward approach is to first assemble the entire plot command (as mentioned in the comments by ‘that other guy’) and then use it in the here document:

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement