Programming2012. 11. 18. 02:57


프로젝트를 뛰다보니, 당장 결과물을 내기에 급급하여 기초도 없이 작업하는 경우가 있다.

특히 Web이 그러한데.. Spring과 javascript 그리고 ajax에 관한 책을 단 1page도 보지않고..

구현하기에는 너무 무리가 있다. 여튼 이번에는 Spring에서 있는 annotatino 방식인 @ReponseBody에

대해서 적어볼까 하낟.


먼저 web-controller 부분은 


 @RequestMapping(value="/ajaxSelectBoardListCnt", method = RequestMethod.POST)

    public @ResponseBody ClassData chkAdmLogin () throws Exception   {

         

        ClassData data = new ClassData();

        data.setData("Testing");

        data.setVersion(true);

        System.out.println("Here we go");

        return data;

    }


servlet.xml에는 다음과 같이 추가한다.

1. beans :

xmlns:mvc="http://www.springframework.org/schema/mvc"

http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd


2.  <context:component-scan base-package="com.samsung.abi" />


3. javascript 함수는 아래와 같이 만든다.


function doAjaxBoardListCnt() {

    $.ajax({

        url: "ajaxSelectBoardListCnt",

        type:"POST",

        //dataType: "application/json",

        //contentType: "text/plain; charset=euc-kr",

        success: function(data) {

            if(data != null)    {

            alert(data.version);

        //        $("#RsltTblAjax").html(data);

            } else {

          //      $("#RsltTblAjax").html("null 입니다.");

            alert('hello');

            }

        }

    });

}

끝. 간단하다.


Get으로 하고싶으면 그냥 post부분을 GET으로 바구면 떙

'Programming' 카테고리의 다른 글

Open SSH Server  (0) 2012.10.08
Being fillled circle / Android programming / Thread example  (0) 2011.10.15
File copy by using windows API  (0) 2011.08.31
Win32 API tutorial  (0) 2011.08.26
Posted by 박세범
Programming2012. 10. 8. 14:47

How to open SSH server on Ubuntu


OpenSSH Server

Introduction

This section of the Ubuntu Server Guide introduces a powerful collection of tools for the remote control of networked computers and transfer of data between networked computers, called OpenSSH. You will also learn about some of the configuration settings possible with the OpenSSH server application and how to change them on your Ubuntu system.

OpenSSH is a freely available version of the Secure Shell (SSH) protocol family of tools for remotely controlling a computer or transferring files between computers. Traditional tools used to accomplish these functions, such as telnet or rcp, are insecure and transmit the user's password in cleartext when used. OpenSSH provides a server daemon and client tools to facilitate secure, encrypted remote control and file transfer operations, effectively replacing the legacy tools.

The OpenSSH server component, sshd, listens continuously for client connections from any of the client tools. When a connection request occurs,sshd sets up the correct connection depending on the type of client tool connecting. For example, if the remote computer is connecting with the sshclient application, the OpenSSH server sets up a remote control session after authentication. If a remote user connects to an OpenSSH server withscp, the OpenSSH server daemon initiates a secure copy of files between the server and client after authentication. OpenSSH can use many authentication methods, including plain password, public key, and Kerberos tickets.

Installation

Installation of the OpenSSH client and server applications is simple. To install the OpenSSH client applications on your Ubuntu system, use this command at a terminal prompt:

sudo apt-get install openssh-client

To install the OpenSSH server application, and related support files, use this command at a terminal prompt:

sudo apt-get install openssh-server

The openssh-server package can also be selected to install during the Server Edition installation process.

Configuration

You may configure the default behavior of the OpenSSH server application, sshd, by editing the file /etc/ssh/sshd_config. For information about the configuration directives used in this file, you may view the appropriate manual page with the following command, issued at a terminal prompt:

man sshd_config

There are many directives in the sshd configuration file controlling such things as communications settings and authentication modes. The following are examples of configuration directives that can be changed by editing the /etc/ssh/ssh_config file.

[Tip]

Prior to editing the configuration file, you should make a copy of the original file and protect it from writing so you will have the original settings as a reference and to reuse as necessary.

Copy the /etc/ssh/sshd_config file and protect it from writing with the following commands, issued at a terminal prompt:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original
sudo chmod a-w /etc/ssh/sshd_config.original

The following are examples of configuration directives you may change:

  • To set your OpenSSH to listen on TCP port 2222 instead of the default TCP port 22, change the Port directive as such:

    Port 2222

  • To have sshd allow public key-based login credentials, simply add or modify the line:

    PubkeyAuthentication yes

    In the /etc/ssh/sshd_config file, or if already present, ensure the line is not commented out.

  • To make your OpenSSH server display the contents of the /etc/issue.net file as a pre-login banner, simply add or modify the line:

    Banner /etc/issue.net

    In the /etc/ssh/sshd_config file.

After making changes to the /etc/ssh/sshd_config file, save the file, and restart the sshd server application to effect the changes using the following command at a terminal prompt:

sudo /etc/init.d/ssh restart
[Warning]

Many other configuration directives for sshd are available for changing the server application's behavior to fit your needs. Be advised, however, if your only method of access to a server is ssh, and you make a mistake in configuringsshd via the /etc/ssh/sshd_config file, you may find you are locked out of the server upon restarting it, or that thesshd server refuses to start due to an incorrect configuration directive, so be extra careful when editing this file on a remote server.

SSH Keys

SSH keys allow authentication between two hosts without the need of a password. SSH key authentication uses two keys a private key and apublic key.

To generate the keys, from a terminal prompt enter:

ssh-keygen -t dsa

This will generate the keys using a DSA authentication identity of the user. During the process you will be prompted for a password. Simply hitEnter when prompted to create the key.

By default the public key is saved in the file ~/.ssh/id_dsa.pub, while ~/.ssh/id_dsa is the private key. Now copy the id_dsa.pub file to the remote host and appended it to ~/.ssh/authorized_keys2:

cat id_dsa.pub >> .ssh/authorized_keys2

Finally, double check the permissions on the authorized_keys2 file, only the authenticated user should have read and write permissions. If the permissions are not correct change them by:

chmod 644 .ssh/authorized_keys2

You should now be able to SSH to the host without being prompted for a password.


간단하다 apt-get install openssh-server 만해도 끝나는듯

port를 변경하려면 root권한 획득후, /etc/ssh/sshd_config 를 열어서 port 부분을 변경해주면 된다.

ssh key 바꾸고 싶으면 아래의 절차에 따라서 진행하면 된다. 끝.

Posted by 박세범
Programming/Perl2012. 10. 5. 02:44



Chapter 04. 사용자 함수



함수의 이름 ? → & 기호가 붙는다.


사용자 함수를 만드는 법에 대해서 알아보자.


Sub NAME

{

}


Call ? → &NAME; 간단하네

& <-- 이걸 생략할 수 있지만, 만약 함수의 구현이 뒤쪽에 되어 있을 경우, &를 반드시 명시해 주어야 한다.

&를 구분하지 않을 경우 이것이 System Library Func인지 아니면 User Function인지 구분하긴 쉽지 않을듯..


use strict pragma를 쓴다 좋은 프로그래밍 습관을 강제적으로 적용받는다.


my는 scope variable을 지정할 때 쓰면 된다.

사용방법은 my ($what, @array) = @_;

이런식으로~?


subroutine func같은 경우 return값은 가장 마지막 연산..

return을 명시해줘도 되는데 귀찮으닌깐 안쓰는게 최고당 ^^;



Chapter 05. 입력과 출력


Linux의 대표적인 3가지 입출력 STDIN, STDOUT, STDERR


$line = <STDIN>

chomp($line)

보통 표준입력을 이렇게 받지만..

if you feel annoyed


chomp($line = <STDIN>)


Diamond operator... <-- Larry 딸내미가 지어줬다고 함..


command line 부분 argument 처리하기

@ARGV ← 인자를 읽어들인다.

ex ) foreach(@ARGV) print


Array를 Interpolation할 때

if print @array <-- 그냥 한줄씩 출력

print "@array" 한칸 띄어진다. 왜? 그렇게 만들었어요



File을 open할는 open method를 이용

open CONFIG, “<dino”


특수문자의 의미는 아래와 같다.

< : Input

> : Output

>> : If file exists, it will add strings(characters)


Perl 5.6?


open CONFIG, “<”, “dino


die Method? → kill the program with the log from $!

Warn is practically same with Die however, it does not close a program.




Print FileHandle “blablabla~~~”


input task using Diamond operator



./a.pl ab cd def

while(<>)

{

print

}

argv에 있는 것들을 읽어 그것을 출력한다



오늘 공부 끄읕~ ^^


'Programming > Perl' 카테고리의 다른 글

Perl 프로그래밍 기본 셋팅  (0) 2012.10.04
Posted by 박세범