I have access to a node of a Linux cluster, on which Mathematica is installed. However, I do not have access to a Linux GUI.
Typically I write and test Mathematica scripts on my Windows personal computer (with the typical GUI/front end). Then, I run the scripts on the Linux terminal because the terminal is significantly faster than my desktop computer (my scripts read and write a lot of data). I use the command:
math < test.txt
test.txt is a text file containing Mathematica code. I have been using this command successfully to run my scripts. I just always need to make sure that I do not try to print graphics to the screen, since I don't have a Linux GUI.
However, now I would like to write a script that prompts the user for input. For example, this code works fine on the Windows GUI:
Print["start"]; str = InputString; Print["string: " <> str]; Print["finish"];
But, it fails on the Linux terminal, generating this console output:
Mathematica 7.0 for Linux x86 (64-bit) Copyright 1988-2008 Wolfram Research, Inc.
Is there any way I can prompt the user for input on a Linux terminal? The input does not necessarily need to be interactive. For example, I can imagine there being a way to pass an input string to
math by a command like:
math -input "This is my input string." < test.txt
but I am not sure what is the syntax to do this.
InputString works on the terminal if I simply enter a terminal using the command:
and then type
InputString in the input prompt. However, this is not how I want to run my scripts, since this (I think) would require me to retype every command, line by line.