# coding: utf-8 """使用法 exec_shell.py コマンドが記載されたxmlファイル コマンドが記載されたxmlファイルのcommandタグをパースし、 パースしたコマンドを実行するスクリプト """ # モジュールインポート from subprocess import Popen,PIPE import xml.etree.ElementTree as et import sys # 変数定義 cmdfile=sys.argv[1] tree=et.parse(cmdfile) cmd=tree.find(".//code").text # 関数定義 def main(cmd): p=Popen(cmd,shell=True,stdout=PIPE,stderr=PIPE) result=p.communicate() return result # メイン処理
