7.13 Shell commands
Shell commands may be executed directly from within Pyxplot by prefixing them with an ! character. The remainder of the line is sent directly to the shell, for example:
!ls -l
Semi-colons cannot be used to place further Pyxplot commands after a shell command on the same line.
|
!ls -l ; set key top left |
It is also possible to substitute the output of a shell command into a Pyxplot command. To do this, the shell command should be enclosed in back-quotes (‘), as in the following example:
a=`ls -l *.ppl | wc -l`
print "The current directory contains %d Pyxplot scripts."%(a)
It should be noted that back-quotes can only be used outside quotes. For example,
|
set xlabel ’‘ls‘’ |
will not work. One way to do this would be
set xlabel `echo "'" ; ls ; echo "'"`
a better way would be to use the os.system or os.popen functions:
|
fileList = os.popen("ls","r").read() set xlabel fileList |
Note that it is not possible to change the current working directory by sending the cd command to a shell, as this command would only change the working directory of the shell in which the single command is executed:
|
!cd .. |
Pyxplot has its own cd command for this purpose, as well as its own pwd command:
|
cd .. |