popen 보기 c

카테고리 없음 2013. 10. 23. 14:21

#include <stdio.h>

#include <stdlib.h>

#include <strings.h>

#include <unistd.h>

int main ()

{

        FILE *fp;

        char buf[1024];

        char *token;

        int cnt;



        fp = popen("/usr/bin/wc -l abc.txt", "r");

        if (fp == NULL)

        {

                printf("ERROR:popen fail\n");

                exit(0);

        }

        fread(buf, 1, 1024, fp);

        pclose(fp);


        printf("buf:%s\n", buf);

        token = (char *) strtok(buf, " ");

        printf("token:%s\n", token);

        cnt = atoi(token);


        printf("cnt:%d\n", cnt);


}


Unhandled exception type IOException 컴파일 에러 때 

아래 코드 추가


import java.io.IOException;


try {

// 원래 코드

} catch (IOException e) {

 System.out.println (ex.toString());

}




java tcp server 소스

java 2013. 10. 14. 11:25

간단한 java tcp server 소스 


http://hks003.tistory.com/130



$ ls  *.class

$ Sever$Connection.class Server$ConnectionManger.class Server$HTTPMirror.class ...


달러 ($) 표시 클래스는 내부 클래스를 뜻한다.

당연히 프로그램 기동 때 필요한 클래스다.




jsp 에서 xss 방어

java 2013. 9. 5. 16:06

import = "java.util.Enumeration"


<%

String requestMethod = request.getMethod();

Enumeration enu = request.getParameterNames();

String sNames = "";


while (enu.hasMoreElements()) {

sNames = (String)enu.nextElement();

if ( request.getParameter(sNames).indexOf("script") > -1 ||

request.getParameter(sNames).indexOf("\"") > -1 ||

request.getParameter(sNames).indexOf("<") > -1 ||

request.getParameter(sNames).indexOf(">") > -1 ) {

response.sendRedirect("/index.html");

}

%>


이에 대한 Dijkstra 의 재밌는 설명


N 개의 원소를 갖는 배열이라면

1 ≤ i < N+1  표시보다는 

0 ≤ i < N     표시가 낫다고 한다.


(http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html)




https://addons.mozilla.org/ko/firefox/addon/add-to-delicious/


다른 버전은 firefox21 에서 잘 작동하지 않는다. 


1045 MySQL 서버에 로그인할 수 없습니다


wamp 설치 후 phpmyadmin 에 로그인할 때 나는 에러이다


사용자 명에 "root" , 비밀번호 는 비워둔 채 엔터하면 된다