2016-08-14 4 views
0

のうち、シェルスクリプトを実行する方法。私はシェルファイルを実行しようとしています。 私はシェルファイルを実行可能にすることはできません。ウィンドウ内のchmod + x filename.shのようなsoemthingを探します。Windowsの場合:</p> <pre><code>python -m http.server --cgi 8000 </code></pre> <p>Serverが稼働していると私はそれにPythonスクリプトを実行することができていますhttp.server使用Srver私のpythonをしたシンプルなCGIパイソンサーバ

Ubuntuの等価リンク:

Content-type text/htmlException happened during processing of request from ('127.0.0.1', 1659) 
Traceback (most recent call last): 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 313, in _handle_request_noblock 
    self.process_request(request, client_address) 


File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 341, in process_request 
    self.finish_request(request, client_address) 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 354, in finish_request 
    self.RequestHandlerClass(request, client_address, self) 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\socketserver.py", line 681, in __init__ 
    self.handle() 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 422, in handle 
    self.handle_one_request() 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 410, in handle_one_request 
    method() 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 645, in do_GET 
    f = self.send_head() 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 953, in send_head 
    return self.run_cgi() 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\http\server.py", line 1161, in run_cgi 
    env = env 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 947, in __init__ 
    restore_signals, start_new_session) 

File "C:\Users\ABC\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1224, in _execute_child 
    startupinfo) 
OSError: [WinError 193] %1 is not a valid Win32 application 
<h1>Hello World</h1> 

コンテンツPythonのファイルの更新:

#!/usr/bin/env python 
print("Content-type text/html") 
print("") 
print("<h1> Hello World </h1 >")` 

は現在、私はこのエラーを取得しています

出力:(ブラウザ画面上)

Hello World 

シェルファイルの内容

#!/bin/bash 
echo "Content-type text/html" 
echo "" 
echo "<h1>Hello World</h1>" ` 

出力:前述のエラー上記

同様の出力をしたいHello World。

+0

HTMLコードをプログラムとして実行しようとしました。だから失敗しても何を期待していますか? – Daniel

+0

は質問を更新しました:予想された現在の出力は何ですか? – wadhwa94

答えて

0

ウィンドウにはbashスクリプトはありません。あなたは非常に限られた構文を持つ.batファイルしか持っていません。スクリプトをfilename.shとして実行しようとすると、ウィンドウは拡張子.shに関連付けられたプログラムを検索しようとし、失敗します。ファイルの名前をfilename.batに変更する必要があります。

関連する問題

 関連する問題