4,052 views
この記事は最終更新から 2374日 が経過しています。
まず初めに、シェルスクリプトファイル exec.sh を作成し、実行属性を付与する。
>>> fh = open('exec.sh','w') >>> fh.write('#!/bin/sh\n') >>> fh.write('export LD_LIBRARY_PATH=/usr/local/lib\n') >>> fh.write('gcc --version\n') >>> fh.write('#end') >>> fh.close() >>> >>> import subprocess as sp >>> args = ['chmod','+x','./exec.sh'] >>> sp.call(args) 0
作成したシェルスクリプトファイルを実行する。
>>> import subprocess as sp >>> args = ['./exec.sh'] >>> sp.call(args) gcc (GCC) 4.9.0 Copyright (C) 2014 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 0
アクセス数(直近7日): ※試験運用中、BOT除外簡易実装済2026-04-19: 0回 2026-04-18: 0回 2026-04-17: 0回 2026-04-16: 0回 2026-04-15: 0回 2026-04-14: 0回 2026-04-13: 0回