[Scilab-users] Problem with dos function

classic Classic list List threaded Threaded
9 messages Options
arctica1963 arctica1963
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] Problem with dos function

Hello,

I have an issue with the dos function for running an external program;
tested in 5.5.2 and 6.1.0 with same result:

--> [s,bOK]=dos('grdinfo crop1.grd')
 s  =

    []
 bOK  =

  T

The result of grdinfo is empty and should give the following if typed at the
command prompt:

D:\Geoscience\Scilab>grdinfo crop1.grd
crop1.grd: Title: Grid computed with Mirone
crop1.grd: Command:
crop1.grd: Remark: File written from Matlab
crop1.grd: Gridline node registration used [Geographic grid]
crop1.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
crop1.grd: x_min: 1.05833333333 x_max: 5.14166666667 x_inc: 0.0166666666667
(1 min) name: longitude n_columns: 246
crop1.grd: y_min: 3.84166666667 y_max: 7.90833333333 y_inc: 0.0166666666667
(1 min) name: latitude n_rows: 245
crop1.grd: z_min: -106.033233643 z_max: 131.578842163 name: z [unknown]
crop1.grd: scale_factor: 1 add_offset: 0
crop1.grd: format: netCDF-4 chunk_size: 246,245 shuffle: on deflation_level:
8

However, dos('dir','-echo') works and list the directory! Is there a bug or
a missing option to apply? In an earlier version (5.4.1) it worked fine.

Thanks

Lester








--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

Dear Lester,

It's hard to help you without being able to reproduce the issue with the
actual file.
Since you are using Scilab on Windows, have you tried
[s, bOK] = powershell("grdinfo crop1.grd")
?

Samuel

Le 17/12/2020 à 13:21, arctica1963 a écrit :

> Hello,
>
> I have an issue with the dos function for running an external program;
> tested in 5.5.2 and 6.1.0 with same result:
>
> --> [s,bOK]=dos('grdinfo crop1.grd')
>   s  =
>
>      []
>   bOK  =
>
>    T
>
> The result of grdinfo is empty and should give the following if typed at the
> command prompt:
> .../...

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
arctica1963 arctica1963
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

Hello Samuel,

Yes I did try the powershell option and it is the same response, the program
runs (boolean result is true) but the result is not resolved in the output.

The external program is using GMT (Generic mapping tools) and so that needs
to be installed to test this issue.

I also installed 5.4.1 to check and that also gives the same problem.

I checked the function in Octave (5.1.0) which looks the same as Scilab and
it gives the proper result:
https://octave.sourceforge.io/octave/function/dos.html

>> dos('grdinfo crop1.grd')
crop1.grd: Title: Grid computed with Mirone
crop1.grd: Command:
crop1.grd: Remark: File written from Matlab
crop1.grd: Gridline node registration used [Geographic grid]
crop1.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
crop1.grd: x_min: 1.05833333333 x_max: 5.14166666667 x_inc: 0.0166666666667
(1 min) name: longitude n_columns: 24
6
crop1.grd: y_min: 3.84166666667 y_max: 7.90833333333 y_inc: 0.0166666666667
(1 min) name: latitude n_rows: 245
crop1.grd: z_min: -106.033233643 z_max: 131.578842163 name: z [unknown]
crop1.grd: scale_factor: 1 add_offset: 0
crop1.grd: format: netCDF-4 chunk_size: 246,245 shuffle: on deflation_level:
8

ans = 0

I have looked at the Octave file, but it uses a "system" function which is
not the same in Scilab:

function [status, text] = dos (command, echo_arg)

  if (nargin < 1 || nargin > 2)
    print_usage ();
  endif

  status = 1;
  text = "";

  ## FIXME: Should this be ispc ()?  There may be an issue with MinGW
  if (! isunix ())
    [status, text] = system (command);
    if (nargin > 1 || nargout == 0)
      printf ("%s\n", text);
    endif
  endif

endfunction

Where is the dos function in Scilab?

Not sure if it is relevant, but testing on Windows 8.

Lester



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

Then you can check if the results are sent to the consolebox instead of
to the Scilab console:
Press F13 or run --> consolebox on to display the consolebox and see its
content.

https://help.scilab.org/docs/6.1.0/en_US/consolebox.html


Le 18/12/2020 à 23:39, arctica1963 a écrit :

> Hello Samuel,
>
> Yes I did try the powershell option and it is the same response, the program
> runs (boolean result is true) but the result is not resolved in the output.
>
> The external program is using GMT (Generic mapping tools) and so that needs
> to be installed to test this issue.
>
> I also installed 5.4.1 to check and that also gives the same problem.
>
> I checked the function in Octave (5.1.0) which looks the same as Scilab and
> it gives the proper result:
> https://octave.sourceforge.io/octave/function/dos.html
> .../...

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
arctica1963 arctica1963
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

Hi Samuel,

Tested with consolebox on and it is empty, so it's not sending data there.

As a test, I did a simple windows copy: dos('copy crop1.grd
crop1a.grd','-echo') and that worked, so no issue with basic windows
commands.

Not sure what else to try unless it's an installation issue?

Lester



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

Le 19/12/2020 à 09:14, arctica1963 a écrit :
> Not sure what else to try unless it's an installation issue?


unix_w, unix_g ... functions


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
Samuel GOUGEON Samuel GOUGEON
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

In reply to this post by arctica1963
Le 19/12/2020 à 09:14, arctica1963 a écrit :
> Not sure what else to try unless it's an installation issue?


In addition to unix_*(), you may also try to redirect the standard error
stream to the standard output:

[s,bOK] = dos('grdinfo crop1.grd 2>&1')


_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
arctica1963 arctica1963
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

HI Samuel,

Tried the unix_*() options with no success, redirect also did not work.

Lester



--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
arctica1963 arctica1963
Reply | Threaded
Open this post in threaded view
|

Re: Problem with dos function

Same issue with console-only Scilab: Scilex,exe and WScilex-cli.exe.

For reference, GMT can be installed from
https://www.generic-mapping-tools.org/
Using Win64 version
https://github.com/GenericMappingTools/gmt/releases/tag/6.1.1

Lester





--
Sent from: http://mailinglists.scilab.org/Scilab-users-Mailing-Lists-Archives-f2602246.html
_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users