echo "this is an example"Then we assign permissions and the result is
[j@localhost physionet]$ chmod 777 example [j@localhost physionet]$ ls -l total 4 -rwxrwxrwx 1 j j 25 Jul 31 20:59 example*Now we are able to run the file from the prompt
[j@localhost physionet]$ ./example this is an exampleWe can see that it functions properly. Now we are going to try to run this small script with Scilab. We begin by calling Scilab from any other window
===========
S c i l a b
===========
scilab-2.6
Copyright (C) 1989-2001 INRIA
Startup execution:
loading initial environment
-->
We have to go to the directory where we are going to store our data files. We can go there with the next command
-->chdir('/home/j/physionet')
ans =
0.
Now we want to repeat the commands from the Scilab prompt
-->unix_g('ls -l')
ans =
!total 4 !
! !
!-rwxrwxrwx 1 j j 25 Jul 31 20:59 example !
Notice that we can assign the result to a variable
-->str = unix_g('ls -l')
str =
!total 4 !
! !
!-rwxrwxrwx 1 j j 25 Jul 31 20:59 example !
-->str
str =
!total 4 !
! !
!-rwxrwxrwx 1 j j 25 Jul 31 20:59 example !
Pay attention to this result because it is very important. We have run a command and the result has been stored in a variable. The command that we have used (`ls') does not belong to Scilab. Now we are going to run the script that we created before
-->unix_g('./example')
ans =
this is an example
-->str2 = unix_g('./example')
str2 =
this is an example
-->[str2;str]
ans =
!this is an example !
! !
!total 4 !
! !
!-rwxrwxrwx 1 j j 25 Jul 31 20:59 example !
Notice that we can store the results of the commands as a matrix of strings. Now we can manipulate the strings like any other Scilab object. Although this matrix is a Scilab variable, it was not produced by Scilab but from the prompt and some very simple script that we created.
The core of this method is the command `unix': from inside Scilab you run a command as if you were in the prompt of the operating system. You have four variants of this command (these commands are identical if you are running Scilab on Windows systems)
Of the different variants of `unix', one of them (`unix_x') creates a fast and powerful visualization window that is especially suited to explore the content of ASCII files.
The next chapters explore the possible use of these tools to make Scilab work in common with other programs.