Skip to main content

If you have used the POSIX shell (“bash”) on VOS, then you know that you can run various POSIX commands and use all of the nifty tricks that bash provides, such as input and output redirection.  But did you know that you can use these same features with many VOS commands?

For example, if you would like to combine the VOS “list” command with the POSIX “more” command, type the following command line into bash:

list | more

If you want to run the output of the list command into a file, say:

list >list.txt

This works because both VOS and POSIX use the same underling VOS port to write output to the terminal or batch file.  The VOS “default_output” port is equivalent to the POSIX “stdout” file.  And the VOS “default_input” port is the same as the POSIX “stdin” file.  Finally, the VOS “terminal_output” port, which is where VOS writes is error messages, is the same as the POSIX “stderr” file.

Here’s a (contrived) example of using bash input redirection on a VOS command.  Create a file named “line_edit.txt” with the following 2 lines in it:

print *

You can then run these line_edit requests against your abbreviations file as follows:

line_edit abbreviations <line_edit.txt

Note that bash runs every command in a new child process.  The child process inherits all I/O attachments and all state from the parent process, so this is not a problem for most commands.  However, any VOS command that modifies the process environment won’t do what you expect.  For example, running the set_library_paths command from within bash will change the library paths of the child process; and this process is destroyed as soon as the command terminates.  If you want to change the paths that are searched by bash, you must make the change using the POSIX method, which is to change the PATH environment variable.

I hope you find these techniques useful.

© 2024 Stratus Technologies.