부패

2010-05-06 2 views
0

에서 IO 스트림 결과를 복사 I는 HTTP 응답에 프로세스의 표준 출력을 보내는 작은 잡종 웹 서버가이 잘 대부분의 시간을 작동부패

response.start(200) do |head,out| 
    head["Content-Type"] = "text/html" 
    status = POpen4::popen4(command) do |stdout, stderr, stdin, pid| 
    stdin.close() 
    FileUtils.copy_stream(stdout, out) 
    FileUtils.copy_stream(stderr, out) 
    puts "Sent response." 
    end 
end 

을하지만 때로는 문자가 중복 얻을. 예를 들어 이것은 "man ls"명령에서 얻은 것입니다.

LS(1)       User Commands       LS(1) 



NNAAMMEE 
     ls - list directory contents 

SSYYNNOOPPSSIISS 
     llss [_O_P_T_I_O_N]... [_F_I_L_E]... 

DDEESSCCRRIIPPTTIIOONN 
     List information about the FILEs (the current directory by default). 
     Sort entries alphabetically if none of --ccffttuuvvSSUUXX nor ----ssoorrtt. 

     Mandatory arguments to long options are mandatory for short options 

일부 신비한 이유 때문에 대문자가 중복됩니다. 아무도 무슨 일이 일어나고 있는지 설명 할 수 있습니까?

답변

2

실제 출력은 man입니다. 표시되는 중복 문자 및 백 스페이스 문자와 같은 다른 문자는 콘솔에 표시 할 때 밑줄 텍스트 등과 같이 출력 서식을 지정하는 데 사용됩니다.

이러한 서식 문자를 필터링하려면 Linux Man Pages HOWTO의 How do I get a plain text man page without all that ^H^_ stuff?에있다.

나는이 종류의 출력에 대해 text/html이 올바른 MIME 유형인지 확신하지 못합니다.

관련 문제