(ubuntu 12.04を使用しています)
私はこのpythonプログラムを作りました:
#!/bin/sh
# -*- coding: utf-8 -*-
#Created on Tue Nov 12 19:44:50 2013
#@author: matthew
import os
print "Multiple Command Runner"
print "<Made by Matthew Cherrey>"
print "-------------------------"
numbcommand = 0
allcoms = []
while 1:
numbcommand = numbcommand + 1
command = raw_input(" Command: ")
allcoms.append(command)
decide = raw_input("Press [Enter] to and another command, press [r] to run all commands: ")
if decide == "r":
break
commands = ""
first = True
for item in allcoms:
if first:
commands = item
else:
commands = commands + " && " + item
os.system(commands)
そして、ターミナルで実行できるようにしたいです。私はPythonエディタを使用しています:Spyderこれには「システム端末で実行」するオプションがあります。これを行うたびに、私のプログラムは完全に機能します。複数のコマンドを入力して、それらをすべて実行できます。/home/matthew/.runallcommands.py --python
ファイルを実行可能ファイルに設定してorを実行すると/home/matthew/.runallcommands.py
、最初にカーソルが「t」になり、次に何かをクリックすると、画面のその領域の写真が撮られ、「OS」という名前の写真として私のホームフォルダ。次に、次のエラー メッセージが表示されます。
matthew@matthew-MS-7721:~$ /home/matthew/.runallcommands.py --python
Warning: unknown mime-type for "Multiple Command Runner" -- using "application/octet-stream"
Error: no such file "Multiple Command Runner"
Warning: unknown mime-type for "<Made by Matthew Cherrey>" -- using "application/octet-stream"
Error: no such file "<Made by Matthew Cherrey>"
/home/matthew/.runallcommands.py: 13: /home/matthew/.runallcommands.py: numbcommand: not found
/home/matthew/.runallcommands.py: 14: /home/matthew/.runallcommands.py: allcoms: not found
/home/matthew/.runallcommands.py: 17: /home/matthew/.runallcommands.py: Syntax error: "(" unexpected (expecting "do")
私のプログラムはスパイダーのターミナルで100%正常に動作したため、ファイルの呼び出し方法と関係があるかどうかはわかりません。