bugGNU Octave - Bugs: bug #31895, error: run: file must exist and be...

 
 

bug #31895: error: run: file must exist and be a valid Octave script file

Submitted by:  Rick T <ratulloch>
Submitted on:  Wed 15 Dec 2010 10:51:28 PM UTC  
 
Category:  None Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  None
Originator Name:  Rick T Open/Closed:  Closed
Release:  3.2.3 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 06 Jan 2011 08:28:33 AM UTC, comment #5: 

I think this problem has been fixed, so I'm closing this report.  If that's not correct, then reopen it or create a new bug report.

John W. Eaton <jwe>
Project Administrator
Mon 20 Dec 2010 01:22:53 PM UTC, comment #4: 

Yes. Before applying your patch, using "source (mfile)" works for me.

Ben Abbott <bpabbott>
Project Member
Mon 20 Dec 2010 03:41:15 AM UTC, comment #3: 

Ben, does it work if you use

source (mfile)

instead of

eval (mfile(1:end-2))

?

I changed the run function to use source instead of just evaluating the name of the script without the file extension:

http://hg.savannah.gnu.org/hgweb/octave/rev/0754a4e271f4

I don't know whether that will solve the original problem,  but it seems like the correct thing for run to do based on its docstring.

John W. Eaton <jwe>
Project Administrator
Fri 17 Dec 2010 01:20:47 AM UTC, comment #2: 

Looks like the error given by run.m is making an improper inference as to what is wrong.

If the example below is run as a script ...

mfile = "test.m";
if (exist (strcat (pwd, filesep, mfile, "file")))
  delete (mfile)
endif
fid = fopen (mfile, "w");
fprintf (fid, "x = 0:0.1:10;\n")
fprintf (fid, "plot (x, sin(x), x, cos(x))")
fclose (fid);
eval (mfile(1:end-2))

I get the error below.

error: Invalid call to test.  Correct usage is:

-- Function File:  test NAME
-- Function File:  test NAME quiet|normal|verbose
-- Function File:  test ('NAME', 'quiet|normal|verbose', FID)
-- Function File:  test ([], 'explain', FID)
-- Function File: SUCCESS = test (...)
-- Function File: [N, MAX] = test (...)
-- Function File: [CODE, IDX] = test ('NAME','grabdemo')

If a "rehash" is added between "fclose(fid)" and "eval(...)", the script runs without error.

Perhaps the error handling should rely upon lasterror?

[msg, msgid] = lasterr;
error (msgid, msg)

Ben Abbott <bpabbott>
Project Member
Thu 16 Dec 2010 06:37:46 AM UTC, comment #1: 

Please provide a self-contained example that demonstrates the problem.

John W. Eaton <jwe>
Project Administrator
Wed 15 Dec 2010 10:51:28 PM UTC, original submission:  

Greetings All

I get this error message when I try and run an m file that creates another m file with an equation in it.

Example:  I use one m file to create another m file called test.m that has the equation in it "y=vert*sin(24);"
then I try and run it I get

>>> run('/home/rat/Documents/octave/eq_research/aa/test.m')

error: run: file must exist and be a valid Octave script file

>>>error: called from:

error:   /usr/share/octave/3.2.3/m/miscellaneous/run.m at line 46, column 2

The m file does exist it is created using the fprintf(fid) commands.  I notice that If I open the m file that is created (test.m) and add a space and delete the space then save it the command will work does anyone know of a better work around then opening each created m file.  It's as though the file is created but it cant see it.  Does anyone have a work around

here's my version

GNU Octave Version 3.2.3
GNU Octave License: GNU General Public License
Operating System: Linux 2.6.32-26-generic #48-Ubuntu SMP Wed Nov 24 10:14:11 UT
C 2010 x86_64
----------------------------------------------------------------------
Package Name  | Version | Installation directory
--------------+---------+-----------------------
       audio *|   1.1.4 | /usr/share/octave/packages/3.2/audio-1.1.4
   multicore *|  0.2.15 | /usr/share/octave/packages/3.2/multicore-0.2.15
        time *|   1.0.9 | /usr/share/octave/packages/3.2/time-1.0.9

Rick T <ratulloch>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bpabbott (Posted a comment)
  • -email is unavailable- added by jwe (Posted a comment)
  • -email is unavailable- added by ratulloch (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.

     

     

     

    Follow 3 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2011-01-06 jwe StatusNeed Info => Fixed
        Open/ClosedOpen => Closed
    2010-12-16 jwe StatusNone => Need Info

    Back to the top


    Powered by Savane 3.5