4,118 views
この記事は最終更新から 2471日 が経過しています。
まず初めに、シェルスクリプトファイル 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-07-26: 0回 2026-07-25: 0回 2026-07-24: 0回 2026-07-23: 1回 2026-07-22: 0回 2026-07-21: 0回 2026-07-20: 0回