1 / 19

CGI (Common Gateway Interface) 를 이용한 실습

CGI (Common Gateway Interface) 를 이용한 실습. Sunmoon univ. Ubiquitous Application Lab shbae. World Wide Web (1). WWW http 프로토콜을 이용하여 html 문서를 전달 Web Server : apache, IIS 등 Web Browser : Internet Explorer, Netscape HTTP (Hyper Text Transfer Protocol) Html 문서의 전달을 정의한 프로토콜

gizi
Télécharger la présentation

CGI (Common Gateway Interface) 를 이용한 실습

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CGI(Common Gateway Interface)를 이용한 실습 Sunmoon univ. Ubiquitous Application Lab shbae

  2. World Wide Web (1) • WWW • http 프로토콜을 이용하여 html 문서를 전달 • Web Server : apache, IIS 등 • Web Browser : Internet Explorer, Netscape • HTTP (Hyper Text Transfer Protocol) • Html문서의 전달을 정의한 프로토콜 • HTML (Hyper Text Markup Language) • Web에서 사용될 하이퍼 텍스트 문서를 만들기 위한 언어 • html tag를 기반으로 원하는 정보를 표현

  3. (1) 요청 Web Server Web Browser (2) 응답 World Wide Web(2) • Web 의 특징 • 일방적인 정보의 전달 • 사용자와의 상호 작용을 지원할 수 없음 • 기본 동작

  4. CGI • CGI (Common Gateway Interface) • 웹 서버와 외부 프로그램간의 연결에 대한 규약 • 상호 작용 지원 • 요청 시점에 따라 다른 html 문서를 제공 • C/C++, Perl, shell program 등을 이용하여 작성

  5. (1) 요청 Web Browser CGI Program Web Server (2) 실행 (3) 결과 (4) 응답 CGI • 기본 동작

  6. Form tag (1) • Form tag • html에서 사용자의 입력, 선택을 위한 tag • text, button, check box 등의 일반적인 GUI 포함 • Form tag의 값 전달 방식(METHOD) • 사용자의 입력을 encoding하여 전달 함 • GET • 입력 값을 URL에 포함시켜 전달 • POST • 입력 값을 표준 입력을 통해 전달 • 입력 값의 길이에 관계 없이 전달 가능

  7. Form tag (2) • Action • 서버가 입력된 데이터를 받아서 처리할 CGI 프로그램 이름. • Name • 폼의 이름. • Target • CGI 프로그램에 의하여 전송되는 데이터를 출력할 윈도우 지정. • EncType • 전송방식이 POST일 경우에, 폼의 데이터 전송시 암호와 방법지정.

  8. Form tag (3) • Form tag 작성 예 • 결과

  9. Form tag (4) • 이름을 입력 받는 form tag • POST 방식으로 값 전달 • Actions을 누르면 ‘CgiProgram.cgi’를 요청

  10. 환경 변수 및 CGI Library • 환경 변수 • Web Server, Web Browser의 정보 • CGI 가 실행될 때 참조하여 사용 가능 • SERVER_SOFTWARE : Server 프로그램 정보 • REMOTE_ADDR : Web Browser의 IP 주소 • CGI Library • CGI 프로그램에서 공통적으로 필요한 함수 모음 • Form tag를 통해 얻은 정보의 parsing 및 decoding이 주된 기능

  11. 첫 번째 CGI 프로그램 (1) • 준비 • CD에 있는 850-Lib디렉토리를 자신의 작업 디렉토리로 복사한다.(/mnt/cdrom/Resource/850-Lib) • 복사한 후에 CGI_Library와 LCD_Library를 각각 make 해준다. % make

  12. 첫 번째 CGI 프로그램 (2) • libletokcgi.so(CGI_Library)파일 복사 • Host 시스템 →크로스 컴파일러의 lib 디렉토리에 복사 %cp ./libletokcgi.so /opt/q+esto/cdt/powerpc-linux/lib(⇐크로스 컴파일러 설치 디렉토리) - Target 시스템 →Target 시스템의 nfs 디렉토리의 lib 디렉토리에 복사 %cp ./libletokcgi.so /opt/nfs/lib(⇐자신의 nfs의 lib) →cgi 프로그램을 실행 할 때 사용

  13. 첫 번째 CGI 프로그램 (3) • cgilib.h 파일 복사 • cgi 프로그램을 컴파일 하려고 하는 호스트에 복사(/opt/nfs/home/work ⇐ 자신의 프로그램 파일 디렉토리) • 컴파일 할 때 사용

  14. 첫 번째 CGI 프로그램 (4) • first.c 코드

  15. 첫 번째 CGI 프로그램 (5) • Compile % ls first.c cgilib.h % powerpc-linux-gcc –lletokcgi –o first.cgi first.c • first.cgi 파일을 nfs 디렉토리의 home/httpd/cgi-bin/에 복사 • 실행 • http://장비 IP/cgi-bin/first.cgi 에 접속 • 실행 결과

  16. LED 제어 CGI 프로그램 (1) • Led.c 코드

  17. LED 제어 CGI 프로그램 (2)

  18. LED 제어 CGI 프로그램 (3) • Compile % powerpc-linux-gcc –lletokcgi –o led.cgi led.c • led.cgi 파일을 nfs 디렉토리의 home/httpd/cgi-bin/에 복사 • 실행 - led_dd.o의 위치mnt/cdrom/Resource/Part4/Driver/LED • led_dd.o 디바이스 드라이버 실행(insmod) • “http://장비 IP/cgi-bin/led.cgi”에 접속

  19. LED 제어 CGI 프로그램 (4) • 실행 결과 • 숫자 입력 후 Submit 버튼을 클릭 - 장비의 LED 변화, 입력한 값이 출력 됨

More Related