[Kst] piping data into kstcmd in a shell script gives syntaxErrors

George Staikos staikos at kde.org
Sat Aug 4 05:40:09 CEST 2007


Hi Wim,

    You can't use # comments inside the echo line.  That should solve  
your problem.

On 4-Aug-07, at 2:23 AM, wim van hoydonck wrote:

> Hi there,
>
> I have an autogenerated shell script (see below) that I use to  
> start kst
> with some commands-line options. So far so good.
>
> Then, in the shell script, I echo some javascript commands and pipe
> them into kstcmd, so that plot labels and axes ranges are
> automatically set.
>
> This all works, but it gives some syntaxError warnings. I do not get
> these syntax errors when I start kstcmd interactively and use a
> loadScript('myscript.js') that contains exactly the same commands
> (except for the backslashes).
>
> [wim at localhost solo]$ ./kst_ctrls.sh
> Attached to Kst session kst-8772
> kst> Error: SyntaxError: Parse error at line 2
> kst> kst> Error: SyntaxError: Parse error at line 2
> kst> Error: SyntaxError: Parse error at line 2
> kst> Time (s)
> kst> Error: SyntaxError: Parse error at line 2
> kst> Pedal
> kst> Error: SyntaxError: Parse error at line 2
> kst> undefined
> kst> [wim at localhost solo]$
>
>
> It might have something to do with my limited knowledge of shell  
> scripting,
> but I'm not really sure.
>
> I also added a small part of the file kst is supposed to read (in case
> anyone wants to try it).
>
> Greetings,
>
> Wim
>
>
> the shell script==========================================
>
> #!/bin/bash
> #
> # shell script auto-generated by Helix
> # based on options in <sim_output>-section of
> # dueca_config.xml
>
> # start kst with options to display pilot controls
> # in a 2-by-2 array
> kst -x 1 -y 2 -y 3 -y 4 -y 5 -m 2 puma_output.csv &
>
> # sleep a little bit
> sleep 3
>
> # now start kstcmd and feed it with the
> # argument of the echo command
> # it will attach itself to the above kst session
> # and set the labels of the four plots and the limits of the y-axes
> echo '# grab the plots in the window
> var p0 = Kst.windows[0].plots[0]; \
> var p1 = Kst.windows[0].plots[1]; \
> var p2 = Kst.windows[0].plots[2]; \
> var p3 = Kst.windows[0].plots[3]; \
>
> # label the x-axes of our plots
> # TODO: use new label possibilities (textsize)
> p0.xAxis.label = "Time (s)"; \
> p1.xAxis.label = "Time (s)"; \
> p2.xAxis.label = "Time (s)"; \
> p3.xAxis.label = "Time (s)"; \
>
> # label the y-axes of our plots
> p0.yAxis.label = "Collective"; \
> p1.yAxis.label = "Lateral Cyclic"; \
> p2.yAxis.label = "Longitudinal Cyclic"; \
> p3.yAxis.label = "Pedal"; \
>
> # set y-axes ranges
> p0.yAxis.scaleRange( -0.1 , 1.1 ); \
> p1.yAxis.scaleRange( -1.1 , 1.1 ); \
> p2.yAxis.scaleRange( -1.1 , 1.1 ); \
> p3.yAxis.scaleRange( -1.1 , 1.1 );' | kstcmd
>
> end of shell script===============================================
>
> contents of puma_output.csv=======================================
>       0.01000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.11000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.21000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.31000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.41000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.51000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.61000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.71000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.81000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       0.91000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       1.01000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       1.11000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       1.21000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       1.31000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       1.41000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       1.51000000      0.65464783      0.00000000       
> 0.00000000      0.00000000
>       1.61000000      0.65464783      0.52206421       
> 0.00000000      0.00000000
>       1.71000000      0.65464783      0.99996948       
> 0.00000000      0.00000000
>       1.81000000      0.65464783      0.99996948       
> 0.00000000      0.00000000
>       1.91000000      0.65464783      0.99996948       
> 0.00000000      0.00000000
>       2.01000000      0.65464783      0.99996948       
> 0.00000000      0.00000000
>       2.11000000      0.65464783      0.99996948       
> 0.00000000      0.00000000
>       2.21000000      0.65464783      0.99996948       
> 0.00000000      0.00000000
>       2.31000000      0.65464783      0.47012329       
> 0.00000000      0.00000000
>       2.41000000      0.65464783      0.24673462       
> 0.00000000      0.00000000
>       2.51000000      0.65464783      0.24154663       
> 0.02340698      0.00000000
>       2.61000000      0.65464783      0.36102295       
> 0.54028320      0.00000000
>       2.71000000      0.65464783      0.66751099       
> 0.72988892      0.00000000
>       2.81000000      0.65464783      0.76101685       
> 0.72988892      0.00000000
>       2.91000000      0.65464783      0.78439331       
> 0.72988892      0.00000000
>
> end of puma_output.csv===========================================
>
> -- 
> Avoid hangovers - stay drunk!
> _______________________________________________
> Kst mailing list
> Kst at kde.org
> https://mail.kde.org/mailman/listinfo/kst

--
George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/





More information about the Kst mailing list