Shell Script with GNUPlot

This is a discussion on Shell Script with GNUPlot within the Linux Programming forums, part of the Platform Specific Boards category; I want a script that would plot something in GNUPlot. I did the following. Code: gnuplot plot 2*x But after ...

  1. #1
    Anirban Ghosh
    Join Date
    Jan 2006
    Posts
    277

    Shell Script with GNUPlot

    I want a script that would plot something in GNUPlot.
    I did the following.

    Code:
    gnuplot
    plot 2*x
    But after I ran using "sh test.sh", only the gnuplot command-line appeared.
    Nothing has been plot.

    Any help please?

  2. #2
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Gnuplot itself is not the shell -- altho I've never used it, I'm pretty sure that is the issue here. A parallel might be bc:

    [root~] bc
    bc 1.06
    Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
    This is free software with ABSOLUTELY NO WARRANTY.
    For details type `warranty'.
    2*4
    8

    (interrupt) use quit to exit.
    quit
    The only shell command issued here is "bc" -- all the rest of it are bc commands, not shell command line commands.

    So if "plot 2*x" is a command you issue to gnuplot after you start it (ie, gnuplot is an interactive command line application), a shell script won't work. One thing you can try which works with bc and might work with gnuplot is:
    [root~] echo -e "2*4\nquit\n" | bc
    8
    Actually, some of that is unnecessary but there's the idea.

    However, I would guess that gnuplot (like bc and many other interactive CLI programs) will accept instructions from a text file (not a shell script, nb). You should be able to create a file listing gnuplot commands named "do.txt" or something and then start it:

    gnuplot do.txt
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by MK27 View Post
    However, I would guess that gnuplot (like bc and many other interactive CLI programs) will accept instructions from a text file (not a shell script, nb). You should be able to create a file listing gnuplot commands named "do.txt" or something and then start it:

    gnuplot do.txt
    MK speaks much truth here. Put your gnuplot commands in a file for your "script" (a batch job, really -- no variables or anything I'm pretty sure) and feed it into gnuplot.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. shell script comparison for two file(text) character wise
    By vaibhavs17 in forum Linux Programming
    Replies: 2
    Last Post: 03-01-2010, 12:47 PM
  2. deallocating a struct containing arrays
    By maxtothemax in forum C Programming
    Replies: 5
    Last Post: 09-28-2009, 07:09 PM
  3. invoking shell script
    By agoel01 in forum C Programming
    Replies: 1
    Last Post: 12-01-2005, 10:37 AM
  4. Game structure, any thoughts?
    By Vorok in forum Game Programming
    Replies: 2
    Last Post: 06-07-2003, 01:47 PM
  5. Arguements with a shell script
    By Doh in forum Linux Programming
    Replies: 1
    Last Post: 11-28-2002, 01:20 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21