Dos function in Scilab

As an observation, the dos function does not function as it should under Windows, and requires a simple workaround.

For example:

[result, bOK]=dos(‘grdinfo faa_test_1m.grd’)

result =

“Error returned from GMT API: GMT_MEMORY_ERROR (25)”

bOK =

F

However, applying a simple function resolves this on Windows:

function [result, bOK]=dos_win(x)
    [result, bOK] = dos('exit |'+ x);
endfunction

This seems to work fine and the “exit” part prevents the cmd terminal launching.

[result, bOK]=dos_win(‘grdinfo faa_test_1m.grd’)

result = [11x1 string]

"faa_test_1m.grd: Title: "
“faa_test_1m.grd: Command: gmt grdcut @earth_faa_01m_p/ -Gfaa_test_1m.grd -R-10/10/-10/10 -V”

"faa_test_1m.grd: Remark: "
“faa_test_1m.grd: Pixel node registration used [Geographic grid]”
“faa_test_1m.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7”
“faa_test_1m.grd: x_min: -10 x_max: 10 x_inc: 0.0166666666667 (1 min) name: longitude n_columns: 1200”

“faa_test_1m.grd: y_min: -10 y_max: 10 y_inc: 0.0166666666667 (1 min) name: latitude n_rows: 1200”

“faa_test_1m.grd: v_min: -104.800018311 v_max: 455.225006104 name: z”
“faa_test_1m.grd: scale_factor: 1 add_offset: 0”
“faa_test_1m.grd: format: netCDF-4 chunk_size: 134,134 shuffle: on deflation_level: 3”
“faa_test_1m.grd: Default CPT: @earth_faa.cpt

bOK =

T

For reference, this issue appeared to start after the transition to Scilab 6.x.x, version 5.5.2 did not have an issue, so not sure what changed. Clearly, the cause of the problem still persists; this was reported on the mailing list previously, but is just something to be aware of on Windows.

Lester

1 Like

Update using Scilab 2025.0.0

The DOS function as listed in the documentation still not working properly under Windows 11 command shell to run external cmd-line programs. The fix quoted before still works.

function [result, bOK]=dos_win(x)
[result, bOK] = dos(‘exit |’+ x);
endfunction

Lester

1 Like