I am trying to plot a graph using expect in my script and want to change the range of x and y axis. my script processes all the commands but when it comes to axis([1 5 1 10], 'normal']) command it give out the error following error :

octave:1>  x = 1:1:3
x =

   1   2   3 

octave:2>  y = load('xsd.txt')
y =

   41.500
   39.200
   41.400

octave:3>  plot(x,y)
octave:4>  grid minor on
octave:5>  xlabel('Test-No.')
octave:6>  ylabel('Results')
octave:7>  invalid command name "1"
    while executing
"1 5 1 10"
    invoked from within
"send " axis([1 5 0 10],'normal')\r""
    (file "./ioctave" line 25)

here's my script:

spawn octave
sleep 1
expect "> " 
sleep 1
send " x = 1:1:3\r"
expect "> "
send " y = load('xsd.txt')\r"
sleep 1
expect "> "
sleep 1
send " plot(x,y)\r"
expect "> "
send " grid minor on\r"
expect "> "
send " xlabel('Test-No.')\r"
expect "> "
sleep 1
send " ylabel('Results')\r"
sleep 1
expect "> "
send " title('Test Results')\r"
expect "> "
send " axis([1 5 1 10],'normal')\r"
expect "> "
send " print('res.jpg')\r"
expect "> "
send "bye\r"

Why is it happening even when all other commands get executed successfully. I tried changing the syntax but I guess the syntax of command " axis([1 5 1 10],'normal') " is correct. I even tried to test the command by entering everything manually and the same command works when I type by hand. WHY!!?

PLZ HELP PLZ HELP!:(

I have found the answer!

You have to use a slash '\[' where ever you enter square brackets to help octave understand the command entered automaticallu/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.