第6回

プログラミング

HPの更新をもっと簡単いすることはできないか

ソースコード

  1. import subprocess
  2. a = ['path="/Users/hirano/mygit/xbp/"',
  3. 'clear',
  4. 'cd $path',
  5. 'echo ""',
  6. 'echo $path',
  7. 'git add .',
  8. 'git commit -m "auto commit"',
  9. 'git push']
  10. subprocess.call(a, shell=True)

説明

シェルスクリプトを用いてシェルスクリプトを用いて、gitで行うHP更新のコマンドを更新のコマンドを実行する。

参考にしたページ一覧

忘れた時の pythonでシェルスクリプト実行
Pythonでシェルコマンドを実行する
PythonでリモートリポジトリにCommit&Pushする最も簡単な方法