を経由して、それを実行する場合にのみ行を読んだとき、EOF私は、ユーザー入力から例外EOFError:カール
をURLやデータのcurlコマンドベースを構築するPythonコードを持っている私は
import os
print ("______________\n")
print " 1.GET "
print " 2.POST "
print " 3.PUT "
print " 4.DELETE "
print ("______________\n")
http = int(raw_input("Select your option : "))
url = raw_input("Paste Your URL : ")
if not http:
http = 3
if http == 1:
cmd = 'curl '+ url
elif http == 2:
data = raw_input("Paste Your Data : ")
cmd = 'curl -g -X POST -H "Content-Type:application/json" -d \''+data+'\' ' + url
elif http == 3:
data = raw_input("Paste Your JSON Data: ")
cmd = 'curl -g -X PUT -H "Content-Type:application/json" -d \''+data+'\' ' + url
else:
cmd = 'curl -g -X DELETE ' + url
print ("_________________________________________\n")
print '\n'
print cmd
print '\n'
print ("_________________________________________\n")
run = raw_input("Do you want to run it ? [y/n]: ")
print '\n'
if run == 'y':
os.system(cmd+'\n')
print '\n'
else:
os.system("clear")
sys.exit()
を持っています
私は
のpython get_curl.py
それを実行します私はその後
______________
1.GET
2.POST
3.PUT
4.DELETE
______________
Select your option : 3
Paste Your URL : http://172.19.242.32:1234/vse/vcpe/002233445567/vlan/104/device/000011223350/duration
Paste Your Data : {"acl_mode": 2, "portal_url": "http://localhost:8888/captive-portal?client_mac=$MAC&ap=$AP-MAC", "duration": 120 }
_________________________________________
curl -g -X PUT -H "Content-Type:application/json" -d '{"acl_mode": 2, "portal_url": "http://localhost:8888/captive-portal?client_mac=$MAC&ap=$AP-MAC", "duration": 120 }' http://172.19.242.32:1234/vse/vcpe/002233445567/vlan/104/device/000011223350/duration
_________________________________________
Do you want to run it ? [y/n]: y
{ "status": 201, "message": "Processed cpe HNS device duration message" }
を持って、私はgithubのの主旨にホストし、私はその要旨を実行
リンク=
それを共有することができ
01私は私のローカルのMac上でそれを実行しているだろうと私は別の結果を持っていないのはなぜ結果
______________
1.GET
2.POST
3.PUT
4.DELETE
______________
Select your option : Traceback (most recent call last):
File "<stdin>", line 11, in <module>
EOFError: EOF when reading a line
?
どうすればいいですか?
おそらく、pythonがパイプと混同されている可能性があります( 'stdin'と' raw_input'に問題があると考えます)? (それで、スクリプトのコードをスクリプトの入力として使用していますか?) – BorrajaX