# sage and nohup

Does anyone understand why the code below, saved in the file input.txt, does not work when it is run with the command

nohup sage < input.txt > output.txt &

(Of course, I use * for the product but it does not appear properly here)?

import sage.combinat.lyndon_word as LW

from sage.combinat.words.shuffle_product import ShuffleProduct_w1w2 as SP

from sage.combinat.free_module import CombinatorialFreeModule as CFM

F=CFM(QQ, ['a','b'])

R.<a,b>=FreeAlgebra(QQ,2)

Module=CombinatorialFreeModule(F.base_ring(),R)

def TP_free_algebra(w1,w2):
if type(w1)==Integer:
if type(w2)==Integer:
return w1*w2*tensor((Module.basis()[1],Module.basis()[1]))
else:
L2=list(w2)
result=0
for i in L2:
result+=w1*i[0]*tensor((Module.basis()[1],Module.basis()[i[1]]))
return result
else:
if type(w2)==Integer:
L1=list(w1)
result=0
for i in L1:
result+=w2*i[0]*tensor((Module.basis()[i[1]],Module.basis()[1]))
return result
else:
L1=list(w1)
L2=list(w2)
result=0
for i in L1:
for j in L2:
result+=i[0]*j[0]*tensor((Module.basis()[i[1]],Module.basis()[j[1]]))
return result

TP_free_algebra(Word('a'),Word('b'))

edit retag close merge delete

Concerning *: Why don't you use the editor to format code like code?

( 2012-01-14 08:58:58 +0200 )edit

Sort by » oldest newest most voted

My code works without nohup. I don't why, but I could not make it work with it, so I used the screen command and was able to do what I want. Thanks for your answer anyway.

more

Does it work without nohup? I haven't used "<" in my nohupped sage jobs -- what is it supposed to do? Also, why not use .sage instead of .txt? I would try

nohup sage input.sage > output.txt &


(after copying input.txt to input.sage)

more