<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def save_string_and_execute_LilyPond(ly_string, filename, command):
 """A helper function for to_png and to_pdf. Should not be used directly."""

    ly_string = '\\version "2.10.33"\n' + ly_string
    if filename[-4:] in ['.pdf', '.png']:
        filename = filename[:-4]
    try:
        f = open(filename + '.ly', 'w')
        f.write(ly_string)
        f.close()
    except:
        return False
    command = 'lilypond %s -o "%s" "%s.ly"' % (command, filename, filename)
    print 'Executing: %s' % command
    p = subprocess.Popen(command, shell=True).wait()
    os.remove(filename + '.ly')
    return True