Getting Started | Documentation | Glish | Learn More | Programming | Contact Us |
Version 1.9 Build 1556 |
|
Package | utility | |
Module | misc |
include "sh.g"
sh | Construct persistent shell client tool |
command | execute command |
done | destroy the tool |
The sh class allows the user to create persistent instances of a shell client, so that the overhead of creating the client can be amortized over many different function calls. This can result in a considerable time savings for functions that iterate over, say, files in a directory. Unlike shellcmd, this is really meant for fairly low level use and there is no logging option. This might be fixed later, if there is demand for it.
- mysh := sh() # create the client - mysh [command=<function>, done=<function>] - mysh.command('ls -1') # The basic use # output in .lines [lines=Glish.txt MS NUAGES_SOLARIS News Rapport.ps Refman.ps aips++ aipsvars aipsviewrc.list bin catalog.g catalogsink.g displaylistbox.g foo.g foo.ps gcal glish.comments ... , status=0, errlines=] - mysh.command('ls sfajlds') # stderr in .errlines # status in .status [lines=, status=2, errlines=sfajlds: No such file or directory] - mysh.command('jasdfjls') [lines=, status=1, errlines=] - files:=mysh.command('ls -1').lines # typical composite use - length(files) 63 - mysh.done() # must be killed explicitly