[Scilab-users] Running external program

Lester Anderson arctica1963 at gmail.com
Thu Dec 3 16:55:33 CET 2015


Hello Stefan,

Thanks for the pointers. I have tried with a small section of scripting:

// Test script to launch and process GMT commands
dos('grd2xyz FAA.grd -ZTLa -V > faa.txt','-echo') // works fine
dos('grdinfo FAA.grd','-echo') // works fine
dos('grdinfo FAA.grd -C | gawk "{nx=$10; ny=$11}; {print nx, ny}" >
nxy.txt','-echo') // error

The third line fails with an error (gawk is in the PATH), perhas due
to the piping (|) or some other issue:

dos('grdinfo FAA.grd -C | gawk "{nx=$10; ny=$11}; {print nx, ny}" >
nxy.txt','-echo')
                                         !--error 3
Waiting for right parenthesis.
at line       4 of exec file called by :
exec('C:\SS20-work\FAA_EAfrica\test_faa.sce', -1)

Are there limitations with this route?

Thanks
Lester

On 3 December 2015 at 13:57, Stefan Elieff <selieff at sgl.com> wrote:
> The command you want is 'dos':
>
> dos('grd2xyz faa.grd -ZTLa > faa.txt')
>
> If the command line is complex or needs to include names defined elsewhere,
> it is sometimes helpful to use msprintf to create the string first
>
> complex_command = msprintf(...)
>
> and then issue it using the string variable
>
> dos(complex_command,'-echo')
>
> The '-echo' is optional but nice to see in the command window.
>
> The resulting 'faa.txt' file from GMT can be read with whatever function
> makes the most sense for the format (fscanfMat perhaps?).
>
> Stefan
>
>
> On 2015-12-03 6:43 AM, Lester Anderson wrote:
>>
>> Hello,
>>
>> I have the windows version of Scilab (currently 5.4.1), but would like
>> to run an external program (e.g. gmt software) and return or use the
>> output in the Scilab code:
>>
>> As a rough algorithm  example (.sce):
>>
>> //run the gmt program grdinfo.exe - extract data as single column
>> z-matrix)
>>
>> grd2xyz faa.grd -ZTLa > faa.txt
>>
>> scilab: assign matrix output to variable for use in Scilab etc.
>>
>> Any pointers would be helpful.
>>
>> Lester
>> _______________________________________________
>> users mailing list
>> users at lists.scilab.org
>> http://lists.scilab.org/mailman/listinfo/users
>>
> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users



More information about the users mailing list