728x90
반응형
#!/bin/bash
##########################################################################
# File Upload BATCH   PROGRAM
#
# 2009.02.09
#
#     make by LEE TAE YOUNG
##########################################################################

#-------------------------------------------------------------------------
# java export
#-------------------------------------------------------------------------
echo "========================= clover plaza File Upload batch start ======================"
echo " start time : `date`"

export JAVA_HOME=/usr/local/java
export JAVA_BIN=$JAVA_HOME/bin
export JAVA_LIB=$JAVA_HOME/lib
export TOMCAT_HOME=/usr/local/apache-tomcat-6.0.18
export PATH=.:$JAVA_BIN:$PATH
export PRJ_HOME=$TOMCAT_HOME/webapps/ROOT
#export PRJ_HOME=/export/home/tylee/clover/CLOVER_click

CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/ibatis-2.3.0.677.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/ibatis-common-2.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/ibatis-dao-2.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/ibatis-sqlmap-2.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/NetComponents-1.3.8.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/postgresql-8.1-405.jdbc3.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/log4j-1.2.15.jar; export CLASSPATH

CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/commons-logging.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/jce-jdk13-119.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/xercesImpl.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/xmlParserAPIs.jar; export CLASSPATH
CLASSPATH=$CLASSPATH:$PRJ_HOME/WEB-INF/lib/j2ssh.jar; export CLASSPATH
export CLASSPATH=.:$CLASSPATH

cd $TOMCAT_HOME/webapps/ROOT/WEB-INF/classes

#-------------------------------------------------------------------------
# java excute
#-------------------------------------------------------------------------

BATCHPROPERTIES=batch.properties
ERROR=0

java -Dfile.encoding=UTF-8 jp.or.cloverplaza.batch.FileUploadBatch $BATCHPROPERTIES >> $TOMCAT_HOME/clover_logs/batch/batch_FileUpload_$(date +%Y%m%d).log

ERROR=$?

exit $ERROR

echo " end time : `date`"
echo "========================= clover plaza File Upload batch end ======================="
728x90
반응형
728x90
반응형

//NetComponents-1.3.8 (http://www.savarese.org/downloads/NetComponents/)  라이브러리 필요

import java.io.IOException;
import java.io.PrintWriter;

import com.oroinc.net.ftp.FTP;
import com.oroinc.net.ftp.FTPClient;
import com.oroinc.net.ftp.FTPConnectionClosedException;
import com.oroinc.net.ftp.FTPReply;

public class FtpManager {

    protected static FTPClient ftp;

    protected static boolean FTPConnect(String server, String username, String password){
        ftp = new FTPClient();
        ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));

        try {
              int reply;
              ftp.connect(server);
              System.out.println("Connected to " + server + ".");

              // After connection attempt, you should check the reply code to verify
              // success.
              reply = ftp.getReplyCode();

              if(!FTPReply.isPositiveCompletion(reply)) {
                ftp.disconnect();
                System.out.println("FTP server refused connection.");
                return false;
              }

            //Login FTP
            if(!ftp.login(username, password)) {
                ftp.logout();
                return false;
            }

            System.out.println("Remote system is " + ftp.getSystemName());

            //Setting BINARY method
            ftp.setFileType(FTP.BINARY_FILE_TYPE);

        }catch(FTPConnectionClosedException e) {
            System.out.println("Server closed connection.");
            e.printStackTrace();
            return false;
        } catch(IOException e) {
            if(ftp.isConnected()) {
                try {
                    ftp.disconnect();
                } catch(IOException f) {
                    //do nothing
                }
            }
            System.out.println("Could not connect to server.");
            e.printStackTrace();
            return false;
        }

        return true;
    }

    protected static boolean FTPConnect(String server, int port, String username, String password){
        ftp = new FTPClient();
        ftp.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));

        try {
              int reply;
              ftp.connect(server, port);
              System.out.println("Connected to " + server + ":" + port);

              // After connection attempt, you should check the reply code to verify
              // success.
              reply = ftp.getReplyCode();

              if(!FTPReply.isPositiveCompletion(reply)) {
                ftp.disconnect();
                System.out.println("FTP server refused connection.");
                return false;
              }

            //Login FTP
            if(!ftp.login(username, password)) {
                ftp.logout();
                return false;
            }

            System.out.println("Remote system is " + ftp.getSystemName());

            //Setting BINARY method
            ftp.setFileType(FTP.BINARY_FILE_TYPE);

        }catch(FTPConnectionClosedException e) {
            System.out.println("Server closed connection.");
            e.printStackTrace();
            return false;
        } catch(IOException e) {
            if(ftp.isConnected()) {
                try {
                    ftp.disconnect();
                } catch(IOException f) {
                    //do nothing
                }
            }
            System.out.println("Could not connect to server.");
            e.printStackTrace();
            return false;
        }

        return true;
    }


    public static void FTPDisconnect(){
        if(ftp.isConnected()) {
            try {
                ftp.disconnect();
                System.out.println("Disconnect to server.");
            } catch(IOException f) {
                // do nothing
                System.out.println("Disconnect Error. : " + f.getMessage());
                f.printStackTrace();
            }
        }
    }

}
728x90
반응형
728x90
반응형
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;

public class ReadProperties {
    public static Properties getInfo(String path){
        Properties batchProps = new Properties();
        try
        {
            InputStream is =
                    new FileInputStream(path);
            batchProps.load(is);
        }
        catch (Exception e)
        {
            System.out.println("Error. : Can't read the config.properties file.");
            return null;
        }
        
        return batchProps;
    }
}
728x90
반응형
728x90
반응형
SFTP 를 사용하기 위한 소스...
라이브러리는 j2ssh-0.2.9-src(http://sourceforge.net/projects/sshtools/(%20j2ssh))를 직접 jar로 만들어 사용...

import com.sshtools.j2ssh.SftpClient;
import com.sshtools.j2ssh.SshClient;
import com.sshtools.j2ssh.authentication.AuthenticationProtocolState;
import com.sshtools.j2ssh.authentication.PasswordAuthenticationClient;
public class J2sshSftpCient 
{
    private SshClient client = null;
    private PasswordAuthenticationClient auth = null;
    private SftpClient sftp = null;
    
    public J2sshSftpCient(String server, String user, String pwd) throws Exception
    {
        try {
            if (server == null || user == null || pwd == null) {
                System.out.println("Parameter is null!");
            }
            client = new SshClient();
            client.setSocketTimeout(70000);
            client.connect(server);

            auth = new PasswordAuthenticationClient();
            auth.setUsername(user);
            auth.setPassword(pwd);
            int result = client.authenticate(auth);
            if (result != AuthenticationProtocolState.COMPLETE) {
                 throw new Exception("Login to " + server + ":22" + 
                      user + "/" + pwd + " failed");
            }
            sftp = client.openSftpClient();
        } catch (Exception e) {
            System.out.println(e);
            throw e;          
        }
    }
    
    public boolean put(String path) throws Exception
    {
        boolean rtn = false;
        try    {
            if (sftp != null) {
                sftp.put(path);
                rtn = true;
            }
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }
    
    public boolean get(String srcFile, String destFile) throws Exception
    {
        boolean rtn = false;
        try {
            if (sftp != null) {
                if (destFile == null)
                    sftp.get(srcFile);
                else
                    sftp.get(srcFile, destFile);
                rtn = true;
            }
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }
    
    public boolean lcd(String path) throws Exception
    {
        boolean rtn = false;
        try {
            if (sftp != null) {
                sftp.lcd(path);
                rtn = true;
            }
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }
    
    public boolean cd(String path) throws Exception
    {
        boolean rtn = false;
        try {
            if (sftp != null) {
                sftp.cd(path);
                rtn = true;
            }
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }
    
    public String pwd() throws Exception
    {
        String rtnStr = null;
        try {
            if (sftp != null) {
                rtnStr = sftp.pwd();
            }
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtnStr;
    }
    
    public boolean chmod(int permissions, String path) throws Exception
    {
        boolean rtn = false;
        try {
            if (sftp != null) {
                sftp.chmod(permissions, path);
                rtn = true;
            }
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }
    
    public boolean rm(String path) throws Exception
    {
        boolean rtn = false;
        try {
            if (sftp != null) {
                sftp.rm(path);
                rtn = true;
            }
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }

    public boolean isClosed() throws Exception
    {
        boolean rtn = false;
        try {
            if (sftp != null)
                rtn = sftp.isClosed();
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }
    
    public boolean logout() throws Exception
    {
        boolean rtn = false;
        try {
            if (sftp != null)
                sftp.quit();
            if (client != null)
                client.disconnect();
            rtn = true;
        } catch(Exception e) {
            System.out.println(e);
        }
        return rtn;
    }
}

728x90
반응형
728x90
반응형
#############################################################
#
# Title : php 5.2.8 source version install for RadHat9 (Success)
# date : 2009.02.26
# Lee Tae Young
#
#############################################################
#참고 글
#http://sugame.tistory.com/206
#http://blog.naver.com/last98?Redirect=Log&logNo=110032735348

#PHP를 설치하기 위해 필요한 라이브러리들...
#zlib install 
#file name : zlib-1.2.3.tar.gz.tar

tar xvf zlib-1.2.3.tar.gz.tar

cd zlib-1.2.3
./configure --prefix=/usr/local/
make
make install

#libconv 
#file name : libiconv-1.9.2.tar.gz.tar

tar xvf libiconv-1.9.2.tar.gz.tar
cd libiconv-1.9.2
./configure --prefix=/usr/local/

make
make install

#libxml2 
#file name : libxml2-sources-2.7.3.tar.gz


tar xvfz libxml2-sources-2.7.3.tar.gz
cd libxml2-2.7.3
./configure --prefix=/usr/local/ --with-zlib=/usr/local/ --with-iconv=/usr/local/
make
make install

#libxslt <--- 설치 실패 하고 넘어갔음..################
#file name : libxslt-1.1.24.tar.gz

tar xvfz libxslt-1.1.24.tar.gz

cd libxslt-1.1.24
./configure --prefix=/usr/local/  --with-libxml-prefix=/usr/local/  --with-libxml-include-prefix=/usr/local/include/  --with-libxml-libs-prefix=/usr/local/lib

make
make install
###############################################
#PHP의 설치
#참고글#############################################
Share Apache 2.0 Handler module을 생성하기 위해 --with-apxs2[=FILE]을 사용한다. [FILE] 은 앞에서 설치한 Apache 디렉터리의 bin 디렉터리의 apxs파일을 이용한다. (--with-apxs2=/usr/local/apache2/bin/apxs)
또한 xml 확장 사용을 명시 하고(--with-xml) 앞서 설치한 libxml, xsl, dom, iconv 등의디렉터리를 설정하고, socket 프로그래밍에 사용할 수 있도록 --enable-sockets 옵션을 설정한다.
우리가 소스로 설치를 한 이유였던 데이터베이스 사용 설정을 추가해야 하는데, DBX를 사용하기 위한 옵션은 --enable-dbx 옵션이다. 
물론 사용하고자 하는 데이터베이스에 대한 옵션을 넣어 주어야 하는데, mysql 의 경우 --with-mysql=[DIR] 이며, 오라클의 경우 --with-oracle=[DIR] 이다. mysql ext/mysqli 확장을 사용하고자 한다면 --with-mysqli 옵션을 추가한다. 이 과정을 순서대로 하면 다음과 같다.
####################################################

#php 압축 해제
 tar xvfz php-5.2.8.tar.gz

#PHP 컴파일 및 설치

cd php-5.2.8
#↓ 이거는 위에서 설치가 제대로 안된 libxslt 때문에 make test 시 실패가 나오는 듯...ㅡ.ㅡ;;
#./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-zlib-dir=/usr/local/ --with-xml --with-libxml-dir=/usr/local/ --with-dom=/usr/local/ --with-iconv --enable-sockets --enable-dbx --with-mysql=/usr/local/mysql/

#다시 아래 글을 참고했음
#http://blog.naver.com/last98?Redirect=Log&logNo=110032735348
####php configure 중..libjpeg.(a|so) 가 없다는 에러...===> (패키지 설치 : X소프트웨어 개발)
./configure --prefix=/usr/local/php-5.2.8 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/usr/local/apache2/conf --with-exec-dir=/usr/local/apache2/bin --with-gd=shared --with-openssl --with-gd --enable-gd-native-ttf --with-zlib --with-jpeg-dir=/usr/lib


# 추가적인 설정을 보려면 ./configure --help를 이용한다.

 make
 make test (<-- 안해도 된다...근데 혹시 모르니 해보도록...)
 make install

#설정파일 복사
cp php.ini-recommended /usr/local/apache2/conf/php.ini

#so 파일 확인
ls -l /usr/local/apache2/modules/libphp5.so

#httpd.conf 수정
vi /usr/local/apache2/conf/httpd.conf
#################################################
62 라인 부근: LoadModule php5_module modules/libphp5.so
318 라인 부근: AddType application/x-httpd-php .php
     AddType application/x-httpd-php-source .phps

#################################################


728x90
반응형
728x90
반응형
#############################################################
#
# Title : postgresql 8.3.6 source version install for RadHat9 (Success)
# date : 2009.02.26
# Lee Tae Young
#
#############################################################
#참고 글
#http://ttongfly.net/zbxe/?mid=database&sort_index=regdate&order_type=desc&page=2&document_srl=45368
#http://blog.naver.com/northshore?Redirect=Log&logNo=30033589147
#http://cafe.naver.com/nipponit.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=662

#압축풀기
tar xvfj postgresql-8.3.6.tar.bz2

cd postgresql-8.3.6

#인스톨
./configure --help

./configure --prefix=/usr/local/pgsql --enable-nls=UTF8 --without-readline --without-zlib --with-perl

make 

make install

#group, user 생성
groupadd postgres

useradd -g postgres postgres

passwd postgres

su - postgres

vi .bash_profile

-------------------------
export PG=/usr/local/pgsql
export PATH=$PATH:$PG/bin
export MANPATH="$MANPATH":$PG/man
export PGLIB=$PG/lib
export PGDATA=$PG/data
-------------------------

source .bash_profile

exit

#data 디렉토리 생성
cd /usr/local/pgsql

mkdir data

chown -R postgres:postgres /usr/local/pgsql/

#데이터베이스를 초기화
su - postgres

cd /usr/local/pgsql

./initdb --encoding=UTF8 -D /usr/local/pgsql/data/ 

#데이터베이스를 가동
./postmaster -D /usr/local/pgsql/data/ &

ps ax|grep post

./psql template1
###################################################################################
Welcome to psql 7.3.2, the PostgreSQL interactive terminal.

Type:  copyright for distribution terms
       h for help with SQL commands
       ? for help on internal slash commands
       g or terminate with semicolon to execute query
       q to quit

template1=#

# 안해도 된다....#######################################################################
우선은 postgres 의 패스워드를 변경하고 postgresql 을 패스워드 모드로 작동하게 하겠습니다.
postgresql 은 기본적으로 아무 사용자가 접근가능한 모드로 작동이 되더군요.이유는 모르겠습니다.
제가 잘못 안 것일 수도 있고..--a..

패스워드를 먼저 변경하도록 하지요.

template1=# alter user postgres with password '1234';
ALTER USER
template1=# select*from pg_user;
usename  | usesysid | usecreatedb | usesuper | usecatupd |  passwd  | valuntil | useconfig
----------+----------+-------------+----------+-----------+----------+----------+-----------
postgres |        1 | t           | t        | t         | ******** |          |
(1 row)

template1=#
###################################################################################

#일단 빠져나온 후 /usr/local/pgsql/data 폴더로 이동하여 pg_hba.conf 파일을 열어서 아래의 내용을 바꿉니다.

cd /usr/local/pgsql/data/

vi pg_hba.conf

###################################################################################
#원격접속용세팅
서버에 직접접속하지 않고 원격으로 데이터베이스에 접근하기 위해서 다음의 세팅이 필요합니다.
/usr/local/pgsql/data/postgresql.conf
-------------------------
listen_addresses = '*'
port = 5432
-------------------------
/usr/local/pgsql/data/pg_hba.conf
-------------------------
host    postgres       postgres       <IP주소>     <인증방식>
-------------------------
###################################################################################

#postgresql 재구동
cd ../bin
./pg_ctl restart -D /usr/local/pgsql/data/
./psql template1

728x90
반응형
728x90
반응형
#############################################################
#
# Title : mysql-5.1.31 source version install for RadHat9 (Success)
# date : 2009.02.26
# Lee Tae Young
#
#############################################################
# 참고로 이용한 글..
#http://kin.naver.com/detail/detail.php?d1id=1&dir_id=10110&eid=+M4+Z45I5dxBLLfy+trYOBlXpC7coFfm&qb=bXlzcWw1IOyEpOy5mA==&enc=utf8&pid=fjUoJsoi5Uhssb/ILMNsss--050675&sid=SaXoddXNpUkAACj7JpU
#http://cafe.naver.com/netack.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=124

#압축 풀기
>tar -xvzf mysql-5.1.31.tar.gz

>cd mysql-5.1.31

#인스톨하기
>./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-charset=utf8

>make

>make install

>cd ..

>rm mysql-5.1.31.tar.gz

#초기 DB 생성
>/usr/local/mysql/bin/mysql_install_db

#user 생성
>userdel mysql

>useradd -m -s /sbin/nologin -g mysql -d /usr/local/mysql/data mysql

#폴더 권한 주기
>chown -R mysql:mysql /usr/local/mysql/data

#PATH 설정
>vi /etc/profile.d/mysql.sh

###########################
#/etc/profile.d/mysql.sh
MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
###########################

>source /etc/profile

#데몬 구동
>/usr/local/mysql/bin/mysqld_safe &

#mysql root 유저의 비밀번호 변경
>/usr/local/mysql/bin/mysqladmin -u root password "infonia()_+"

#데몬 설정
>echo '/usr/local/mysql/bin/mysqld_safe&' >> /etc/rc.d/rc.local

#설치 확인
>ps -ef | grep mysql

>netstat -an | grep LISTEN | grep 3306

728x90
반응형
728x90
반응형
2009.02.26 - 드디어 RadHat의 환경 설치가 끝났다. 처음으로 완성했다는 느낌이 드는군...!!

###############################################################
# VMware : Red Hat Linux release 9 (Shrike)
# Kernel 2.4.20-8 on an i686
# 2009.02.26
# Lee Tae Young
###############################################################

# IP : 192.168.130.152
# submask : 255.255.255.0
# Gateway : 192.168.130.254
# DNS 1 : 192.168.14.1
# DNS 2 : 192.168.14.2
# proxy : 192.168.130.80 (port: 8080)

#root 비번 : infonia()_+
#mysql 비번 : infonia()_+

# 사용자 : tylee/dlxodud1234
# postgres 사용자 : postgres/postgres
# mysql 사용자 : mysql (외부로그인 불가능 ==> root로 접근해서 로그인)

#telnet, FTP 접근 가능함

#설치 프로그램

ant 1.7.1
java 1.6.12

tomcat 6.0.18
apache 2.2.11
tomcat-connectors 1.2.15

postgresql 8.3.6 (charset : UTF8)
mysql 5.1.31 (charset : UTF8)

php 5.2.8
libxml2 2.7.3
libiconv 1.9.2
zlib 1.2.3
728x90
반응형
728x90
반응형

간단하게 사용하자..복잡한건 싫으니...ㅋㅋㅋ


   FileReader fr = new FileReader( new File("C\test.csv");
   BufferedReader br = new BufferedReader( fr );

   String csvStr = "";
   String tmpStr = "";
   while(tmpStr != null)
   {
    tmpStr = br.readLine(); //한 라인씩 읽어 들임
    System.out.println("!!!!!!!!!tmpStr = " + tmpStr);
    if(tmpStr != null)
    {
     csvStr = csvStr + tmpStr + "||";
    }
   }
   
   System.out.println("#########csvStr = \n" + csvStr + "\n##################");
   

728x90
반응형
728x90
반응형



728x90
반응형

+ Recent posts