Redirecting IO stream
eharetea

Redirecting the input output stream using the << symbol in the c or bash shell. This is useful when you wish to run another program that is initialized in the shell through a command.

Redirecting the input output stream using the << symbol in the c or bash shell. This is useful when you wish to run another program that is initialized in the shell through a command.

Date Created:Tuesday October 28th, 2008 08:51 PM
Date Modified:Tuesday January 19th, 2010 10:44 PM

This demonstrates usage using stk, the command to invoke a scheme prompt. Lets say we write a file my-stk:

stk << ENDCAT
(load "$1")
ENDCAT
Then chmod the file:
chmod +x my-stk
Then edit your .cshrc, .bashrc, .profile or whichever you are using:
alias my-stk location-to-the-folder-my-stk-is-in/my-stk
Now you are ready to call the command after starting a new terminal session:
my-stk somefile.scm
This will open up the scheme prompt, then load the file, then close the scheme prompt. It will print all output to the terminal. For stk in particular, we can keep the prompt open using a few methods: stk's preferred method:
stk -load somefile.scm
Using shell redirection and piping with stk's interactive flag:
cat somefile.scm - | stk -interactive
The "cat somefile.scm -" combines the contents of somefile.scm and the standard input. To invoke the interactive read-eval-print loop, the interactive flag must be set.