From: <pl...@pi...> - 2008-03-31 15:57:00
|
On Mon, 31 Mar 2008 16:32:41 +0200, Ethan A Merritt <merritt@u.washington.edu> wrote: > On Monday 31 March 2008 04:02, pl...@pi... wrote: >> Hi, >> >> I appear to have hit a limitation on setting up a command string for >> system command. I have a "simple" bash command line that works in a >> terminal: >> >> bash-3.2#tail -n1 "../htdocs/data/adc.data"| awk 'format= " c3=%g\n >> c4=%g\n c5=%g\n" {printf format,$3,$4,$5}' >temps.tmp >> bash-3.2#cat temps.tmp >> c3=1.796 >> c4=1.676 >> c5=2.788 >> >> However, when I try to replicate this from within gnuplot is seems not >> to >> get correct send to awk >> >> >> system "tail -n1 '../htdocs/data/adc.data'| awk 'format= \" c3=%g\n >> c4=%g\n c5=%g\n\" {printf format,$3,$4,$5}' >temps.tmp " >> >> awk throws an error back to gnuplot: >> >> gnuplot> load "control.gnu" >> awk: format= " c3=%g >> awk: ^ unterminated string >> >> >> For some reason it seems not to see the second \" > > No. The error message is exactly correct; the problem is that the > carriage return (\n) immediatedly after the c3=%g is terminating the > awk command. It is safer to define a complex string in single > quotes rather then double quotes. > Hi, thanks for the explaination. I got _around_ this issue by using ; instead of newlines. But having spent a lot of time swapping quotes around and delimitting them and other tricks but I never found a solution to reproduce what I had working in bash to work from system command. I've managed to do what I need but that sort of thing bugs me. Is it just my lack of imagination or is this an inherant limitation of the command itself being a quoted string? Apologies for imagining this may have been a bug ;) /peter. > >> I have tried to rearrange this in different ways but it always seems to >> hit the same root cause. >> >> Is this a possible bug in the parser? >> >> Thx, Peter. >> >> ------------------------------------------------------------------------- >> Check out the new SourceForge.net Marketplace. >> It's the best place to buy or sell services for >> just about anything Open Source. >> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace >> _______________________________________________ >> gnuplot-beta mailing list >> gnu...@li... >> https://lists.sourceforge.net/lists/listinfo/gnuplot-beta >> > |