Message Boards Message Boards

GROUPS:

I cannot pass any script to `math`, in a command line

Posted 9 years ago
10028 Views
|
2 Replies
|
1 Total Likes
|

I want to run some lines of Mathematica8 code by a command-line call for math. As a test, I save just the following code in a file test.m:

Put[1+1,"/home/tghfsi/Desktop/Test.txt"];

but when I type in Linux terminal:

tghfsi@Toughee:~$ math -script /home/tghfsi/Desktop/Test.m

the file Test.txt is not created and it seems that nothing has happened. Since the code results correct when I execute it in Mathematica notebook and the .txt file is created in specified place, the problem cannot be from code or file path specification. What I'm not sure about is that if the above command pass the .m file to math kernel, at all. As a not trained Mathematica 8 user, I'd appreciate any useful answer or comment.

POSTED BY: Toughee Eager
2 Replies
Posted 9 years ago

I don't think it is because of a permission issue, since I can get math kernel command prompt by simply typing math, and then I can normally do calculations. I also tried Print instead of Put but nothing happened! I don't know if it helps, but when I type math -initfile test.m, I only get math kernel command prompt, ready to accept inputs, with no reaction to my .m file, like this
In[1]:

POSTED BY: Toughee Eager

You can test your ability to pass a script by writing a script with

Print[1+1]

This should print 2 to standard out. My output:

$ math8 -script Test1.m
2
$

I executed a script with

Put[1+1,"~/Test.txt"]

with

$ math8 -script Test2.m
$

and a Test.txt was created in my home directory with 2 in it. I am wondering if you are seeing a permissions issue.

POSTED BY: Jason Grigsby
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract