Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

As far as I know sage is not aware of piped inputs. It does have the -c switch by which it can run commands "on-the-fly". You can use a while loop and collect all the code into a string and pass it on to sage. For this, you need to tell the while loop to stop collecting the code when some special string is present. Let us say the string is EOD. Then the following is the basic syntax of the sage part of the pipelines:

# IFS='' is needed to preserve leading spaces
# -r is needed to read in raw mode, for example to preserve \ line continuation
while IFS='' read -r line; do
if [[ "${line}" = "EOD" ]]; then
    sage -c "${thecode}"; thecode=""
else
    thecode="${thecode}
${line}"
fi
done

Can not seem to answer this question in full! I will add the example in the comments.

As far as I know sage is not aware of piped inputs. It does have the -c switch by which it can run commands "on-the-fly". You can use a while loop and collect all the code into a string and pass it on to sage. For this, you need to tell the while loop to stop collecting the code when some special string is present. Let us say the string is EOD. Then the following is the basic syntax of the sage part of the pipelines:

# IFS='' is needed to preserve leading spaces
# -r is needed to read in raw mode, for example to preserve \ line continuation
while IFS='' read -r line; do
if [[ "${line}" = "EOD" ]]; then
    sage -c "${thecode}"; thecode=""
else
    thecode="${thecode}
${line}"
fi
done

Can not seem to answer this question in full! I will add It seems my shell code is creating issues with this website!! Anyway, here is the example in the comments.pastebin: http://pastebin.com/c3mb6USs

As far as I know sage is not aware of piped inputs. It does have the -c switch by which it can run commands "on-the-fly". You can use a while loop and collect all the code into a string and pass it on to sage. For this, you need to tell the while loop to stop collecting the code when some special string is present. Let us say the string is EOD. Then the following is the basic syntax of the sage part of the pipelines:

# IFS='' is needed to preserve leading spaces
# -r is needed to read in raw mode, for example to preserve \ line continuation
while IFS='' read -r line; do
if [[ "${line}" = "EOD" ]]; then
    sage -c "${thecode}"; thecode=""
else
    thecode="${thecode}
${line}"
fi
done

Can not seem to answer this question in full! It seems my shell code is creating issues with this website!! Anyway, here is the example in pastebin: http://pastebin.com/c3mb6USs

Notes:

  1. the three parts of the pipelines will not run in parallel. If you have myprogram1 | shell code | myprogram2 then when any of the there parts are running, then the other parts will be idle.
  2. the shell code is really just a shell code, so you can create a bash shell script, called "sage_shell_code" for example, and then just run it as myprogram1 | sage_shell_code | myprogram2.

As far as I know sage is not aware of piped inputs. It does have the -c switch by which it can run commands "on-the-fly". You can use a while loop and collect all the code into a string and pass it on to sage. For this, you need to tell the while loop to stop collecting the code when some special string is present. Let us say the string is EOD. Then the following is the basic syntax of the sage part of the pipelines:

# IFS='' is needed to preserve leading spaces
# -r is needed to read in raw mode, for example to preserve \ line continuation
while IFS='' read -r line; do
if [[ "${line}" = "EOD" ]]; then
    sage -c "${thecode}"; thecode=""
else
    thecode="${thecode}
${line}"
fi
done

Can not seem to answer this question in full! It seems my shell code is creating issues with this website!! Anyway, here is the example in pastebin: http://pastebin.com/c3mb6USs

Notes:

  1. the three parts of the pipelines will not run in parallel. If you have myprogram1 | shell code | myprogram2 then when any of the there three parts are running, then the other parts will be idle.
  2. the shell code is really just a shell code, so you can create a bash shell script, called "sage_shell_code" for example, and then just run it as myprogram1 | sage_shell_code | myprogram2.

As far as I know sage is not aware of piped inputs. It does have the -c switch by which it can run commands "on-the-fly". You can use a while loop and collect all the code into a string and pass it on to sage. For this, you need to tell the while loop to stop collecting the code when some special string is present. Let us say the string is EOD. Then the following is the basic syntax of the sage part of the pipelines:

# IFS='' is needed to preserve leading spaces
# -r is needed to read in raw mode, for example to preserve \ line continuation
while IFS='' read -r line; do
if [[ "${line}" = "EOD" ]]; then
    sage -c "${thecode}"; thecode=""
else
    thecode="${thecode}
${line}"
fi
done

Can not seem to answer this question in full! It seems my shell code is creating issues with this website!! Anyway, here is the example in pastebin: http://pastebin.com/c3mb6USs

Notes:

  1. the three parts of the pipelines will not run in parallel. parallel in general. If you have myprogram1 | shell code | myprogram2 then when any of the three parts are running, the other parts might be idle. If the sage part is the slowest, which it could be because it is launching a new sage process every time, then this will be idle.remain the bottleneck.
  2. the shell code is really just a shell code, so you can create a bash shell script, called "sage_shell_code" for example, and then just run it as myprogram1 | sage_shell_code | myprogram2.