2

So I have a csv, and I have a plt file. I run gnuplot plt-file.plt and a png is born.

But if I run ssh sameuser@samemachine 'gnuplot plt-file.plt' I get a pngcario error.

The csv: sar.csv

time,               average io writes 
4/15/2014 22:28,    6.040546875
4/15/2014 22:28,    7.943100586
4/15/2014 22:29,    8.686162109
4/15/2014 22:29,    7.693891602
4/15/2014 22:30,    8.579804688
4/15/2014 22:30,    7.900537109

The plt:

clear
reset
print "sar"
set terminal pngcairo transparent enhanced font "arial,25" fontscale 1.0 size 1920, 1080
set key outside bottom center box title "sar" enhanced
set key maxrows 4
set key font ",25" spacing 1 samplen 2.9 width 2 height 1
set xlabel "Time (hours)" font ",25"
set ylabel "Utilization (%)" font ",25"

set output "./sar.png"
set title "sar" font ",35"
set datafile separator ","
set timefmt "%Y-%m-%d %H:%M:%S"
set ytics font ",25"

set style line 1 lt 1 lc rgb "red" lw 4

show style line

offset = 0
starting_time = 37824
t0(x)=(offset=($0==0) ? x : offset, x - offset)

plot "./sar.csv" using (t0(timecolumn(1))/3600):2 every ::3 ls 1 t "sar" with lines

Final note: I've compiled gnuplot with the png flag. I just needed any sort of standard image format.

CornSmith
  • 1,957
  • 1
  • 19
  • 35
  • 2
    Hmm, one guess would be, that your self-compiled gnuplot binary isn't found when you login with ssh. Usually, different initialization file are read when using an login shell or a shell via ssh. Type `which gnuplot` in both cases to see if the very same gnuplot binary is used in both cases. – Christoph May 29 '14 at 18:02
  • You are correct! And typing the full path out made it work. It's odd that it doesn't source my .bashrc/.bash_profile by default though. – CornSmith May 29 '14 at 18:21
  • 2
    AFAIK the `.profile` is used (at least on Debian). So you must change the `PATH` also here. – Christoph May 29 '14 at 18:24
  • Well it seems not to source it automatically, but I changed the call from `ssh 'do stuff'` to `ssh '. ~/.profile; do stuff'` and it works. – CornSmith May 29 '14 at 18:58
  • 1
    Does that also help with your other question http://stackoverflow.com/q/23813559/2604213 ? – Christoph May 29 '14 at 20:34
  • Yes, I just retested and the problem was 100% the binary and not the GNUTERM variable. Thanks – CornSmith May 30 '14 at 16:50

1 Answers1

1

That means, that your self-compiled gnuplot probably isn't found when you log-in with ssh. Type which gnuplot in both cases to see which binary is used.

Usually when using ssh you get a non-interactive shell, which sources different configuration files and has different environmental variables than a login shell, see e.g. Why does an SSH remote command get fewer environment variables then when run manually?.

So you can either change the respective configuration files (which ones are used, depends on your distribution), or you can use the full path to the gnuplot binary.

Community
  • 1
  • 1
Christoph
  • 47,569
  • 8
  • 87
  • 187