bugGNU Octave - Bugs: bug #49825, 64-bit Octave on Windows: system...

 
 

bug #49825: 64-bit Octave on Windows: system command always fails

Submitter:  S. M. Hashemi <atomerz>
Submitted:  Sun 11 Dec 2016 07:36:50 AM UTC
   
 
Category:  Documentation Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Documentation
Status:  Fixed Assigned to:  None
Originator Name:  Open/Closed:  * Closed
Release:  * 4.2.0 Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Tue 05 Sep 2017 10:44:33 PM UTC, comment #6: 

I updated the help text for system to note that the shell used for executing commands varies between operating systems.  I also changed the example code to use '&' rather than ';' so it will execute reliably on UNIX or Windows platforms.  See cset http://hg.savannah.gnu.org/hgweb/octave/rev/eef8c31ffe97.

Rik <rik5>
Group administrator
Tue 13 Dec 2016 08:44:03 PM UTC, comment #5: 

I have always developed in a unix environment. Unfortunately I now have to use Windows, but luckily octave is packaged with most of the unix environment, to be usable.

Because of this background, I assumed the system command starts a (unix) shell, as per unix man page: "system() executes a command specified in command by calling /bin/sh -c command"
However on windows it looks like a cmd.exe shell is started.

Personally I think a warning about this difference would be appropriate in the help of the command. At least state that the given example only works on linux.

Wrapping a the system command in a sh -c "" results in 'proper' behavior.

kire pudsje <kpc>
Mon 12 Dec 2016 08:21:03 PM UTC, comment #4: 

Sorry, spoke too early. No problem with the & in between. However when running the example from "help system":

For example,

          [status, output] = system ("echo foo; exit 2");

will set the variable 'output' to the string 'foo', and the
variable 'status' to the integer '2'.


I get

>> [status, output] = system ("echo foo; exit 2")
status = 0
output = foo; exit 2


kire pudsje <kpc>
Mon 12 Dec 2016 08:07:21 PM UTC, comment #3: 

No problem here with 4.2.0 on win10, using the 64bit zip-file.
Maybe try running it first in the terminal command by hand in cmdshell.bat?
Also is your intention really to start a background process (single &)?. Otherwise either use && or ; in between


$ bash -c "echo hi & exit 2"; echo $?
hi
2

$ true; echo $?
0

$ false; echo $?
1


kire pudsje <kpc>
Sun 11 Dec 2016 10:25:08 AM UTC, comment #2: 

It might be something in my system. I'm using this for an online course and when I posted the problem its forums one person replied and said they don't have this problem.
Is there a log or something? so that I can check to see exactly why I'm getting status = 1 all the time?

S. M. Hashemi <atomerz>
Sun 11 Dec 2016 09:01:14 AM UTC, comment #1: 

Works fine with development version:

GNU Octave, version 4.3.0+
Copyright (C) 2016 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type 'warranty'.

Octave was configured for "x86_64-w64-mingw32".

  <snip>

>> [status, output] = system("echo hi & exit 2")
status =  2
output = hi


Provisionally setting status to "Works for me"

Philip Nienhuis <philipnienhuis>
Group Member
Sun 11 Dec 2016 07:36:50 AM UTC, original submission:  

When I run 64-bit octave  (zip or installer) and enter the following command:
[status, output] = system("echo hi & exit 2")

I always get status = 1 and no output. I struggled with this a couple of days until I used the 32-bit version and it works fine now.

S. M. Hashemi <atomerz>

 

(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 rik5 (Posted a comment)
  • -email is unavailable- added by kpc (Posted a comment)
  • -email is unavailable- added by atomerz (Submitted the item)
  • -email is unavailable- added by atomerz
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-09-05 rik5 CategoryOctave Function Documentation
        Item GroupIncorrect Result Documentation
        StatusWorks For Me Fixed
        Open/ClosedOpen Closed
        Operating SystemMicrosoft Windows Any
    2016-12-11 philipnienhuis StatusNone Works For Me
    2016-12-11 atomerz Carbon-Copy- Added atomerz

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code