def shellsub(command):
    """shellsub(command) --> command formatted for remote shell invocation"""
    import re
    command = re.compile("'").sub("\\'", command)
    command = re.compile('"').sub('\\"', command)
    command = re.compile('\\$').sub('\\\\$', command)
    command = re.compile('\\(').sub('\\\\(', command)
    command = re.compile('\\)').sub('\\\\)', command)
    return command
