perl 관련하여 문의드립니다.

monovision의 이미지

LVS 구축과 관련하여 ldirectord 를 사용중인데 이벤트 변경이 되게 할 때마다 문자를 보내게 하기 위해서 소스를 수정할려고 하는데 도통 알 수가 없어서 문의 드립니다.

&ld_log("Quiescent $log_args (Weight set to 0)");
&ld_log("Restored $log_args (Weight set to 1)");

소스에서 위처럼 함수를 호출하면 아래처럼 로그가 찍힙니다.

[Wed Jan 21 06:30:06 2009|ldirectord|27436] Quiescent real server: 220.95.xxx.xxx:80 (220.95.xxx.xxx:80) (Weight set to 0)
[Wed Jan 21 06:30:06 2009|ldirectord|27436] Restored real server: 220.95.xxx.xxx:80 (220.95.xxx.xxx:80) (Weight set to 1)

ld_log 의 함수는 다음처럼 정의가 되어 있구요.

sub ld_log
{
    my ($message) = (@_);
 
        my $now = localtime();
 
    &ld_debug(2, $message);
    chomp $message;
    if ($opt_d) {
        print STDERR "$message\n";
    } elsif ($SUPERVISED eq "yes") {
        print "[$now] $message\n";
    } elsif ( $LDIRLOG =~ /^\/(.*)/ ) {
        unless (open(LOGFILE, ">>$LDIRLOG")
                and print LOGFILE "[$now|$CFGNAME|$$] $message\n"
                and close(LOGFILE)) {
            print STDERR "$message\n";
                return 1;
            }
    }
    else {
        # Assume LDIRLOG is a logfacility, log to syslog
        syslog( "info", "$message" );
    }
    return(0);
}

유사한 함수를 호출했을때 ip 와 port (각 2개씩) 를 뽑아오고 싶은데 도통 뽑지를 못하겠습니다. ㅡ.ㅡ;;;
저기서 ip 와 port 를 뽑아올려면 어떻게 해야하나요 ?

sub send_sms
{
    my ($message) = (@_);
    print STDERR "$message\n";
 
        my $now = localtime();
 
    &ld_debug(2, $message);
    chomp $message;
    print STDERR "$message\n";
    system("/root/send_sms.sh $message");
    return(0);
}

보내는 메세지를 인자로 받는 쉘 스크립트를 만들고 ld_log 로그 함수에서 필요없다고 생각하는 부분을 제외하고 위처럼 system 함수를 이용해서 만들었는데요....
system 함수 자체가 실행되지가 않습니다. 인자가 넘어오는건 둘째 치구요.

system 함수의 사용법도 틀린건지 궁금합니다.

perl 은 다가가기에는 너무나 머네요...

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.