This chapter of documentation relates to the Mozilla SpiderMonkey File Object. The Mozilla SpiderMonkey File Object web page does not have much documentation, so it is documented here. Anyone using SpiderMonkey File Object is welcome to use this for their reference outside of FreeSWITCH as well, since this is Mozilla's code instead of anything specific to FreeSWITCH.
In order to ensure that you have this you must have JS_HAS_FILE_OBJECT=1 in mozilla.build.sh when jslib is built (part of the source distribution). In future releases FreeSWITCH should have this enabled by default, however testing to ensure this works on all platforms is being conducted and until that is complete it will not be by default. Note: the new build system appears to make it default now.
The File object lets you manipulate files.
- filename - the filename including path to open
Note: if you put a | before the name it will execute a command and let you write to that command. If you put a | after the filename it will let you execute a command and read its output. The code prohibits both a pipe before and after the same command. If you want that you will have to open 2 files, one which is on a FIFO (mkfifo may be handy) and the other that is the program you wish to exec.
var fd = new File("| cat -v | lpr -h"); // might be interesting var fd = new File("netstat -an|"); // might also be interesting
fd = new File("/tmp/blah");
- File.input -- stdin
- File.error -- stderr
- File.output -- stdout