LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices



Reply
 
Search this Thread
Old 09-19-2009, 05:37 PM   #1
paulianna2002
LQ Newbie
 
Registered: Jul 2006
Posts: 3

Rep: Reputation: 0
Question xargs and gnuplot


Hi All,

Seems I have an xargs stdin problem that I don't understand.

I have a script (call it myscript.sh) that takes the names of one or more file(s) specified on the command line and creates a single gnuplot command file containing multiple records, one for each specified file. Each of those records is terminated by a gnuplot "pause -1" command that suspends execution until the user presses the enter key. Sort of like this:

gnuplot commands for first .dat file
pause -1


gnuplot commands for second .dat file
pause -1

etc,etc,etc

If I run 'myscript.sh file1.dat file2.dat', it works as expected and gnuplot waits for me to press the enter key before moving onto the next plot.

But, if I do something like 'ls file*.dat | xargs myscript.sh' gnuplot runs through all of the plots without waiting for me to press enter.

So, gnuplot is getting something from stdin effectively making my pause commands useless.

Any ideas would be greatly appreciated.

Thanks in advance.
 
Old 09-19-2009, 06:01 PM   #2
nidsche
LQ Newbie
 
Registered: Jun 2008
Location: Germany
Posts: 21

Rep: Reputation: 16
Quote:
Originally Posted by paulianna2002 View Post
If I run 'myscript.sh file1.dat file2.dat', it works as expected and gnuplot waits for me to press the enter key before moving onto the next plot.

But, if I do something like 'ls file*.dat | xargs myscript.sh' gnuplot runs through all of the plots without waiting for me to press enter.

So, gnuplot is getting something from stdin effectively making my pause commands useless.
Maybe you would like to use
Code:
for i in `ls file*.dat`; do
   myscript.sh $i
done
this should solve the problem. My assumption is that the behaviour comes through the way xargs is calling your script or due to the piping.

Best regards Norbert
 
Old 09-19-2009, 06:14 PM   #3
paulianna2002
LQ Newbie
 
Registered: Jul 2006
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks Norbert,

I am aware of the technique you suggested...unfortunately it is not optimal for me in this case. By placing multiple records in a single gnuplot command file, one window opens (I am running this under X) and I have to place it with a mouse click. Then, as I press enter, new plots come up in the same window until I get through all of them.

Using your suggestion, a new window opens for each instance...each would have to be placed with the mouse before plot generation. It would work, but in some cases I have a large volume of plots to look through and the extra mousing would slow things down too much.

Thanks for taking the time to answer
 
  


Reply

Tags
gnuplot, xargs


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using xargs SBN Linux - General 2 04-07-2008 08:44 PM
Xargs -i problems. Glaurung Linux - Software 2 10-25-2007 04:23 AM
`wc`, `xargs` h/w Programming 11 09-30-2007 05:22 PM
xargs yawe_frek Linux - Software 1 04-15-2007 05:26 PM
xargs and my own script harmster Linux - Software 4 05-07-2005 11:35 AM


All times are GMT -5. The time now is 06:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration