Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Subprocess is somewhat baroque, but you could make a convenience function and put it in your init.sage file, e.g.:

import subprocess def make_it_so(acommand): ''' Uses subprocess module to return the output of a shell command ''' return subprocess.Popen(acommand,shell=True,stdout=subprocess.PIPE).communicate()[0]

and then sage: make_it_so('pwd') '/Users/mh\n'

Subprocess is somewhat baroque, but you could make a convenience function and put it in your init.sage file, e.g.:

import subprocess
def make_it_so(acommand):
    '''
    Uses subprocess module to return the output of a shell command
    '''
    return subprocess.Popen(acommand,shell=True,stdout=subprocess.PIPE).communicate()[0]

subprocess.Popen(acommand,shell=True,stdout=subprocess.PIPE).communicate()[0]

and then

sage: make_it_so('pwd')
'/Users/mh\n'

'/Users/mh\n'