176142998

  BlogJava :: 首页 :: 联系 :: 聚合  :: 管理
  116 Posts :: 0 Stories :: 45 Comments :: 0 Trackbacks

#

package com.org.softwore.util;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.SocketException;

import org.apache.commons.net.telnet.TelnetClient;

import com.org.softwore.domain.TelnetInfo;

public class TelnetUtil {
 private TelnetClient telnet = new TelnetClient("VT220");
 private InputStream in;
 private PrintStream out;
 private String prompt = ">";
 String s;

 public void TelnetCmd(TelnetInfo telnetInfo) throws SocketException,
   IOException, InterruptedException {

  // 防火墙中高级的网络连接设置的本地连接取消选择
  // Connect to the specified server
  telnet.connect(telnetInfo.getServerIp(), telnetInfo.getServerPort());
  // Get input and output stream references
  in = telnet.getInputStream();
  out = new PrintStream(telnet.getOutputStream());

  // Login telnet
  readUntil("login: ");
  write(telnetInfo.getServerUser());
  readUntil("password: ");
  write(telnetInfo.getServerPwd());
  readUntil(prompt);

  // 执行命令
  if (telnetInfo.getMap() != null) {
   int a = 0;
   for (Integer id : telnetInfo.getMap().keySet()) {
    String temp = telnetInfo.getMap().get(id);
    write(temp);
    // 处理ftp登录,不需要执行readUntil(prompt)
    if (temp.startsWith("ftp")) {
     a = 2;
    }
    if (a > 0) {
     a = a - 1;
     continue;
    } else {
     readUntil(prompt);
    }

   }
  }
  System.out.println("\n");
 }

 public String readUntil(String pattern) throws IOException {
  char lastChar = pattern.charAt(pattern.length() - 1);
  StringBuffer sb = new StringBuffer();
  // boolean found = false;
  char ch = (char) in.read();

  while (true) {
   sb.append(ch);
   if (ch == lastChar) {
    if (sb.toString().endsWith(pattern)) {
     // 处理编码,界面显示乱码问题
     byte[] temp = sb.toString().getBytes("iso8859-1");
     System.out.print(new String(temp, "GBK"));
     return new String(temp, "GBK");
    }
   }
   ch = (char) in.read();
  }
 }

 public void write(String value) throws InterruptedException {
  out.println(value);
  out.flush();
  Thread.sleep(1000);
 }

 public void disconnect() throws IOException {
  telnet.disconnect();
 }
}


package com.org.softwore.domain;

import java.io.Serializable;
import java.util.TreeMap;

public class TelnetInfo implements Serializable {

 /**
  *
  */
 private static final long serialVersionUID = -6592407260449335815L;
 private String serverIp;
 private String serverUser;
 private String serverPwd;
 private int serverPort;
 private String ftpIp;
 private String ftpUser;
 private String ftpPwd;
 private String ftpPort;
 private TreeMap<Integer, String> map;

 public TreeMap<Integer, String> getMap() {
  return map;
 }

 public void setMap(TreeMap<Integer, String> map) {
  this.map = map;
 }

 public String getServerIp() {
  return serverIp;
 }

 public void setServerIp(String serverIp) {
  this.serverIp = serverIp;
 }

 public String getServerUser() {
  return serverUser;
 }

 public void setServerUser(String serverUser) {
  this.serverUser = serverUser;
 }

 public String getServerPwd() {
  return serverPwd;
 }

 public void setServerPwd(String serverPwd) {
  this.serverPwd = serverPwd;
 }

 public int getServerPort() {
  return serverPort;
 }

 public void setServerPort(int serverPort) {
  this.serverPort = serverPort;
 }

 public String getFtpIp() {
  return ftpIp;
 }

 public void setFtpIp(String ftpIp) {
  this.ftpIp = "ftp " + ftpIp;
 }

 public String getFtpUser() {
  return ftpUser;
 }

 public void setFtpUser(String ftpUser) {
  this.ftpUser = ftpUser;
 }

 public String getFtpPwd() {
  return ftpPwd;
 }

 public void setFtpPwd(String ftpPwd) {
  this.ftpPwd = ftpPwd;
 }

 public String getFtpPort() {
  return ftpPort;
 }

 public void setFtpPort(String ftpPort) {
  this.ftpPort = ftpPort;
 }

}



package com.org.softwore.service;

public interface TelnetService {

 public boolean windowsTelnetDownLoad();

 public boolean windowsTelnetUpLoad();

 public boolean windowsTelnetUpGrade();
 
 public boolean windowsTelnetTomcat(String stats);
 
 public boolean windowsTelnetBackUpSoftware();
}



package com.org.softwore.service.impl;

import java.io.IOException;
import java.net.SocketException;
import java.util.TreeMap;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.org.softwore.domain.TelnetInfo;
import com.org.softwore.service.TelnetService;
import com.org.softwore.util.TelnetUtil;

@Transactional
@Service("telnetService")
public class TelnetServiceImpl implements TelnetService {

 /**
  * 上传升级问价到ftp服务器
  */
 @Override
 public boolean windowsTelnetUpLoad() {
  boolean reslut = false;

  TelnetInfo telnetInfo = new TelnetInfo();
  telnetInfo.setServerIp("127.0.0.1");
  telnetInfo.setServerUser("administrator");
  telnetInfo.setServerPwd("123456");
  telnetInfo.setServerPort(23);

  TreeMap<Integer, String> map = new TreeMap<Integer, String>();
  map.put(1, "ftp 10.39.62.45");
  map.put(2, "admin");
  map.put(3, "admintianyi");
  map.put(4, "bin");
  map.put(5, "mkdir test1");
  map.put(6, "cd /test1");
  map.put(7, "put c:\\upgrade\\appMarketWebApi.zip");
  map.put(8, "put c:\\upgrade\\T_RANKSWITCHTEMP.sql");
  map.put(9, "bye");
  telnetInfo.setMap(map);

  TelnetCmd(telnetInfo);
  return reslut;
 }
 
 /**
  * 下载升级程序和文件
  */
 @Override
 public boolean windowsTelnetDownLoad() {
  boolean reslut = false;

  TelnetInfo telnetInfo = new TelnetInfo();
  //telnet
  telnetInfo.setServerIp("127.0.0.1");
  telnetInfo.setServerUser("administrator");
  telnetInfo.setServerPwd("123456");
  telnetInfo.setServerPort(23);

  TreeMap<Integer, String> map = new TreeMap<Integer, String>();
  map.put(1, "cd c:\\");
  map.put(2, "rd test /s /q");
  map.put(3, "mkdir test");
  map.put(4, "ftp 10.39.62.45");
  map.put(5, "admin");
  map.put(6, "admintianyi");
  map.put(7, "bin");
  map.put(8, "lcd c:\\test");
  map.put(9, "cd test1");
  map.put(10, "get appMarketWebApi.zip");
  map.put(11, "get T_RANKSWITCHTEMP.sql");
  map.put(12, "bye");
  telnetInfo.setMap(map);

  TelnetCmd(telnetInfo);
  return reslut;
 }
 
 /**
  * 服务器开启和关闭
  */
 @Override
 public boolean windowsTelnetTomcat(String stats) {
  //安装tomcat7,使用服务来进行启动和停止
  boolean reslut = false;

  TelnetInfo telnetInfo = new TelnetInfo();
  telnetInfo.setServerIp("127.0.0.1");
  telnetInfo.setServerUser("administrator");
  telnetInfo.setServerPwd("123456");
  telnetInfo.setServerPort(23);

  // 需要执行的sql语句
  TreeMap<Integer, String> map = new TreeMap<Integer, String>();
  if(stats.equals("start")){
   map.put(1, "net start Tomcat7");
  }
  if(stats.equals("stop")){
   map.put(1, "net stop Tomcat7");
  }
  telnetInfo.setMap(map);

  TelnetCmd(telnetInfo);
  return reslut;
 }
 
 /**
  * 备份软件程序
  */
 @Override
 public boolean windowsTelnetBackUpSoftware(){
  boolean reslut = false;
  
  TelnetInfo telnetInfo = new TelnetInfo();
  telnetInfo.setServerIp("127.0.0.1");
  telnetInfo.setServerUser("administrator");
  telnetInfo.setServerPwd("123456");
  telnetInfo.setServerPort(23);
  
  // 需要执行的sql语句
  TreeMap<Integer, String> map = new TreeMap<Integer, String>();
  //执行sql脚本
  map.put(1, "cd c:\\");
  map.put(2, "rd testback /s /q");
  map.put(3, "mkdir testback");
  map.put(4, "cd c:\\testback");
  map.put(5, "mkdir appMarketWebApi");
  map.put(6, "xcopy \"c:\\Tomcat 7.0\\webapps\\appMarketWebApi\"  appMarketWebApi /s /y");
  telnetInfo.setMap(map);
  
  TelnetCmd(telnetInfo);
  
  return reslut;
  
 }
 
 
 /**
  * 执行sql脚本和升级程序
  */
 @Override
 public boolean windowsTelnetUpGrade() {
  boolean reslut = false;

  TelnetInfo telnetInfo = new TelnetInfo();
  telnetInfo.setServerIp("127.0.0.1");
  telnetInfo.setServerUser("administrator");
  telnetInfo.setServerPwd("123456");
  telnetInfo.setServerPort(23);

  // 需要执行的sql语句
  TreeMap<Integer, String> map = new TreeMap<Integer, String>();
  //执行sql脚本
  map.put(1, "sqlplus appstore/appstore@appstore226");
  map.put(2, "@c:\\test\\T_RANKSWITCHTEMP.sql");
  map.put(3, "exit");
  
  //执行升级程序
  map.put(5, "cd c:\\test");
  map.put(6, "unzip appMarketWebApi.zip");
  map.put(7, "xcopy appMarketWebApi \"c:\\Tomcat 7.0\\webapps\\appMarketWebApi\" /s /y");
  
  telnetInfo.setMap(map);

  TelnetCmd(telnetInfo);
  return reslut;
 }

 /**
  * 公共的调用执行telnet命令
  * @param telnetInfo
  * @return
  */
 public boolean TelnetCmd(TelnetInfo telnetInfo) {
  boolean reslut = false;
  if (telnetInfo != null) {
   TelnetUtil telnet = new TelnetUtil();
   try {
    telnet.TelnetCmd(telnetInfo);
    telnet.disconnect();
    reslut = true;
   } catch (SocketException e) {
    e.printStackTrace();
   } catch (IOException e) {
    e.printStackTrace();
   } catch (InterruptedException e) {
    e.printStackTrace();
   }
  }
  return reslut;
 }
}


package com.org.softwore.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;

import com.org.softwore.service.TelnetService;

@Controller("telnetController")
public class TelnetController {

 @Autowired
 @Qualifier("telnetService")
 private TelnetService telnetService;

 /**
  * 上传升级问价到ftp服务器
  */
 public void windowsTelnetUpLoad() {
  telnetService.windowsTelnetUpLoad();
 }

 /**
  * 下载升级程序和文件
  */
 public void windowsTelnetDownLoad() {
  telnetService.windowsTelnetDownLoad();
 }

 /**
  * 备份软件程序
  */
 public void windowsTelnetBackUpSoftware() {
  telnetService.windowsTelnetBackUpSoftware();
 }

 /**
  * 服务关闭
  */
 public void windowsTelnetStopTomcat() {
  String stats = "stop";
  telnetService.windowsTelnetTomcat(stats);
 }

 /**
  * 执行sql脚本和升级程序
  */
 public void windowsTelnetUpGrade() {
  telnetService.windowsTelnetUpGrade();
 }

 /**
  * 服务开启
  */
 public void windowsTelnetStartTomcat() {
  String stats = "start";
  telnetService.windowsTelnetTomcat(stats);
 }
}



package com.org.softwore.service;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.org.softwore.controller.TelnetController;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( { "/applicationContext.xml" })
public class TelnetUtilTest {

 @Autowired
 @Qualifier("telnetController")
 private TelnetController telnetController;

 /**
  * 上传升级问价到ftp服务器
  */
 @Test
 public void windowsTelnetUpLoad() {
  telnetController.windowsTelnetUpLoad();
 }

 /**
  * 下载升级程序和文件
  */
 @Test
 public void windowsTelnetDownLoad() {
  telnetController.windowsTelnetDownLoad();
 }

 /**
  * 备份软件程序
  */
 @Test
 public void windowsTelnetBackUpSoftware() {
  telnetController.windowsTelnetBackUpSoftware();
 }

 /**
  * 关闭服务
  */
 @Test
 public void windowsTelnetStopTomcat() {
  telnetController.windowsTelnetStopTomcat();
 }

 /**
  * 执行sql脚本和升级程序
  */
 @Test
 public void windowsTelnetUpGrade() {
  telnetController.windowsTelnetUpGrade();
 }

 /**
  * 启动服务
  */
 @Test
 public void windowsTelnetStartTomcat() {
  telnetController.windowsTelnetStartTomcat();
 }
}

posted @ 2011-04-13 17:34 飞飞 阅读(2582) | 评论 (0)编辑 收藏

为了进行系统维护操作,有时需要再windows和linux或Unix系统之间互传文件,虽然有很多工具可以实现该功能,但我还是觉得命令行来的方便快捷,起初使用linux的scp命令,总是不成功,网上也没有相关介绍,经过几次努力之后,终于成功的摸索出了scp命令在写windows的路径时的写法,于是马上下了出来,与大家分享:

从linux系统复制文件到windows系统:scp /oracle/a.txt  administrator@192.168.3.181:/d:/

在linux环境下,将windows下的文件复制到linux系统中:scp administrator@192.168.3.181:/d:/test/config.ips  /oracle

请注意:因为windows系统本身不支持ssh协议,所以,要想上面的命令成功执行,必须在windows客户端安装ssh for windows的客户端软件,比如winsshd,使windows系统支持ssh协议才行。

posted @ 2011-04-13 15:57 飞飞 阅读(594) | 评论 (0)编辑 收藏

commons-net-2.0.jar
log4j-1.2.15.jar


package com;

import java.io.InputStream;
import java.io.PrintStream;

import org.apache.commons.net.telnet.TelnetClient;
import org.apache.log4j.Logger;

public class TelnetHandler {
 private static final Logger logger = Logger.getLogger(TelnetHandler.class);
 private TelnetClient telnet = new TelnetClient("VT220");
 private InputStream in;
 private PrintStream out;
 private String prompt=" ";
 String s;

 public void TelnetCmd(String server, String user, String password) {
  try {
   // Connect to the specified server
   telnet.connect(server, 23);
   logger.info("Login............................");
   // Get input and output stream references
   in = telnet.getInputStream();
   out = new PrintStream(telnet.getOutputStream());
   // Login
   readUntil("login: ");
   write(user);
   readUntil("password: ");
   write(password);
   // Advance to a prompt
   readUntil(prompt);
  } catch (Exception e) {
   e.printStackTrace();
   logger.info("logon failed", e);
  }
 }

 public String readUntil(String pattern) {
  try {
   char lastChar = pattern.charAt(pattern.length() - 1);
   StringBuffer sb = new StringBuffer();
   // boolean found = false;
   char ch = (char) in.read();

   while (true) {
    System.setProperty("GBK", "iso8859-1");
    System.out.print(ch);
    sb.append(ch);
    if (ch == lastChar) {
     if (sb.toString().endsWith(pattern)) {
      // System.out.print( sb.toString());
      return sb.toString();
     }
    }
    ch = (char) in.read();
   }
  } catch (Exception e) {
   e.printStackTrace();
  }
  return null;
 }

 public void write(String value) {
  try {
   out.println(value);
   out.flush();
//   System.out.println(value);
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public String sendCmd(String command) {
  try {
   write(command);
   return readUntil(s + prompt);
  } catch (Exception e) {
   e.printStackTrace();
  }
  return null;
 }

 public void disconnect() {
  try {
   telnet.disconnect();
  } catch (Exception e) {
   e.printStackTrace();
  }
 }

 public static void main(String[] args) {
  try {
   logger.info("发送命令开始");
   TelnetHandler telnet1 = new TelnetHandler();
   telnet1.TelnetCmd("127.0.0.1", "administrator", "123456");
   // Exec Cmd
//   telnet1.sendCmd("dir");
   telnet1.sendCmd("cd c:\\test");
   telnet1.disconnect();
//   telnet1.sendCmd("xcopy c:\\httpdownload.txt c:\\test");
   
   logger.info("发送命令结束");
   
   
  } catch (Exception e) {
   e.printStackTrace();
  }
 }
}

posted @ 2011-04-12 17:37 飞飞 阅读(831) | 评论 (0)编辑 收藏

1、建一个Project取名为SOAP
2、将axis-1_4\webapps\axis\WEB-INF\lib下的所有文件拷贝到你的SOAP工程文件下
3、新建一个HelloWord.java
package com;
public class HelloWord {
public String getHelloWord(userInfo userInfo) {
return "hi!:" + userInfo.getName() + "| " + userInfo.getPassword()
+ " | " + userInfo.getArea();
}
}
 
4、新建一个userInfo.java 对象
package com;
public class userInfo implements java.io.Serializable{
/**
 * 
 */
private static final long serialVersionUID = -1536718814867769008L;
String name;
String password;
String area;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getArea() {
return area;
}
public void setArea(String area) {
this.area = area;
}
}
5、在WEB-INF\server-config.wsdd 文件添加以下内容(注意颜色标记的地方时跟soap相关的地方)
<?xml version="1.0" encoding="UTF-8"?>
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
<handler type="java:org.apache.axis.handlers.http.URLMapper"
name="URLMapper" />
<service name="HelloWord" provider="java:RPC">
<parameter name="className" value="com.HelloWord" />
<parameter name="allowedMethods" value="getHelloWord" />
<beanMapping languageSpecificType="java:com.userInfo" qname="ns:userInfo" xmlns:ns="urn:BeanService"/>
</service>
<transport name="http">
<requestFlow>
<handler type="URLMapper" />
</requestFlow>
</transport>
</deployment> 
6、web.xml 内容
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web
Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Apache-Axis</display-name>
<servlet>
<servlet-name>AxisServlet</servlet-name>
<display-name>Apache-Axis Servlet</display-name>
<servlet-class>
org.apache.axis.transport.http.AxisServlet
    </servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/servlet/AxisServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>*.jws</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AxisServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
<welcome-file>index.html</welcome-file>
<welcome-file>index.jws</welcome-file>
</welcome-file-list>
</web-app>
7、访问路径 http://localhost:8080/SOAP/services/HelloWord?wsdl
8、使用soapUI 3.6.1 生成客户端JUNIT测试代码.进行单元测试!设置soapui的axis参数
9、生成客户端JUNIT测试代码
 
 
10、将生成的代码放到SOAP工程下。修改测试用例。
 
 
11、执行测试,查看结果:
posted @ 2011-04-01 17:21 飞飞 阅读(1776) | 评论 (1)编辑 收藏

Nginx作为一个后起之秀,他的迷人之处已经让很多人都投入了他的怀抱。配置简单,实现原理简单。做一个负载平衡的再好不过了。

其原理:

简单介绍一下他的安装及配置过程

官方网站
http://wiki.codemongers.com/Main

一、依赖的程序

1. gzip module requires zlib library
2. rewrite module requires pcre library
3. ssl support requires openssl library

二、安装
./configure
make
make install

默认安装的路径是/usr/local/nginx

更多的安装配置
./configure --prefix=/usr/local/nginx
--with-openssl=/usr/include (启用ssl)
--with-pcre=/usr/include/pcre/ (启用正规表达式)
--with-http_stub_status_module (安装可以查看nginx状态的程序)
--with-http_memcached_module (启用memcache缓存)
--with-http_rewrite_module (启用支持url重写)


三、启动及重启
启动:nginx
重启:kill -HUP `cat /usr/local/nginx/logs/nginx.pid`
测试配置文件:nginx -t

简单吧,安装,启动都比较方便。

四、配置文件
http://wiki.codemongers.com/NginxFullExample

#运行用户
user nobody nobody;
#启动进程
worker_processes 5;
#全局错误日志及PID文件
error_log logs/error.log notice;
pid logs/nginx.pid;
#工作模式及连接数上限
events {
#工作模式有:select(标准模式),poll(标准模式),kqueue(高效模式,适用FreeBSD 4.1+, OpenBSD 2.9+, NetBSD 2.0 and MacOS X),
#epoll(高效模式,本例用的。适用Linux 2.6+,SuSE 8.2,),/dev/poll(高效模式,适用Solaris 7 11/99+, HP/UX 11.22+ (eventport), IRIX 6.5.15+ 和 Tru64 UNIX 5.1A+)
use epoll;
worker_connections 1024;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#设定mime类型
include conf/mime.types;
default_type application/octet-stream;
#设定日志格式
log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';
  log_format download    '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$http_range" "$sent_http_content_range"';
  #设定请求缓冲
client_header_buffer_size 10k;
large_client_header_buffers 4 4k;

#开启gzip模块,要求安装gzip 在运行./config时要指定
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;

#设定访问日志
access_log logs/access.log main;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;

#设定负载均衡的服务器列表
upstream backserver {
#weigth参数表示权值,权值越高被分配到的几率越大
#本例是指在同一台服务器,多台服务器改变ip即可
server 127.0.0.1:8081 weight=5;
server 127.0.0.1:8082;
server 127.0.0.1:8083;
}
  #设定虚拟主机,默认为监听80端口,改成其他端口会出现问题
server {
listen 80;
server_name test.com www.test.com;
charset utf8;
#设定本虚拟主机的访问日志
access_log logs/test.com.log main;
#如果访问 /images/*, /js/*, /css/* 资源,则直接取本地文件,不用转发。但如果文件较多效果不是太好。
location ~ ^/(images|js|css)/ {
root /usr/local/testweb;
expires 30m;
}

#对 "/" 启用负载均衡
location / {
proxy_pass http://backserver;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
#设定查看Nginx状态的地址,在运行./config 要指定,默认是不安装的。
location /NginxStatus {
stub_status on;
access_log on;
auth_basic "NginxStatus";
#是否要通过用户名和密码访问,测试时可以不加上。conf/htpasswd 文件的内容用 apache 提供的 htpasswd 工具来产生即可
#auth_basic_user_file conf/htpasswd;
}
}
posted @ 2010-11-25 21:15 飞飞 阅读(187) | 评论 (0)编辑 收藏

ATI Installer HOWTO for SUSE/Novell users
openSUSE 10.2
If you want or need to use the latest and greatest ATI driver, continue here .
Use  YaST -> Software -> Change installation Source -> Add  Protocol: http  Server Name: : www2.ati.com  Directory on Server: suse/10.2to add the ATI http server as additional installation source.Now use  YaST -> Software -> Install and Delete Softwareto install the ATI/fglrx driver. Select the following packages:  x11-video-fglrxG01  ati-fglrxG01-kmp-<kernel-flavor><kernel-flavor> depends on your installed kernel. Check with"uname -r" for installed default/smp/bigsmp kernel. Use "sax2 -r"for X.Org configuration.SUSE LINUX 10.1 / SLES10 / SLED10
If you want or need to use the latest and greatest ATI driver, continue here .
Update your Kernel via YOU (YaST Online Update). Use  YaST -> Software -> Change installation Source -> Add  Protocol: http  Server Name: : www2.ati.com  Directory on Server: suse/sle10to add the ATI http server as additional installation source.Now use  YaST -> Software -> Install and Delete Softwareto install the ATI/fglrx driver. Select the following packages:  x11-video-fglrx  ati-fglrx-kmp-<kernel-flavor><kernel-flavor> depends on your installed kernel. Check with "uname -r" for installed default/smp/bigsmp kernel. Use "sax2 -r"for X.Org configuration.Manual driver installation for SUSE LINUX 10.0, SLES9, NLD9 and earlier
Since ATI driver release 8.16.20 the ATI installer needs to be usedto create SUSE/Novell RPMs. Download the ATI installer from the ATI website.  http://www.ati.com --> Drivers & Software --> LinuxIt is possible to create RPMs for the following SUSE/Novell distros.This information has been retrieved by using the installer itself:  ati-driver-installer-8.35.5-x86.x86_64.run --listpkg[...]SuSE Packages:        SuSE/NLD9-IA32  NLD9        SuSE/SLES9-IA32  SLES9        SuSE/SUSE91-IA32 SUSE 9.1        SuSE/NLD9-AMD64  NLD9 (x86_64)        SuSE/SLES9-AMD64 SLES9 (x86_64)        SuSE/SUSE91-AMD64 SUSE 9.1 (x86_64)        SuSE/SUSE100-IA32 SUSE 10.0        SuSE/SUSE92-IA32 SUSE 9.2        SuSE/SUSE93-IA32 SUSE 9.3        SuSE/SUSE100-AMD64 SUSE 10.0 (x86_64)        SuSE/SUSE92-AMD64 SUSE 9.2 (x86_64)        SuSE/SUSE93-AMD64 SUSE 9.3 (x86_64)        SuSE/SLED10-IA32 SLED10        SuSE/SLES10-IA32 SLES10        SuSE/SUSE101-IA32 SUSE 10.1        SuSE/SLED10-AMD64 SLED10 (x86_64)        SuSE/SLES10-AMD64 SLES10 (x86_64)        SuSE/SUSE101-AMD64 SUSE 10.1 (x86_64)        SuSE/SUSE102-IA32 openSUSE 10.2        SuSE/SUSE102-AMD64 openSUSE 10.2 (x86_64) Example:--------Create a RPM for SUSE 10.0 (i386) by using the installer.  ./ati-driver-installer-8.35.5-x86.x86_64.run --buildpkg SuSE/SUSE100-IA32Afterwards install the created RPM by using the rpm command. In thementioned example above this would be:  rpm -Uhv fglrx_6_8_0_SUSE100-8.35.5-1.i386.rpmThe postinstall script of this RPM will try to compile the requiredkernel module. If this fails, you'll get a message how to proceed.You still need to configure the driver with SaX2. Details can be foundin /usr/share/doc/packages/fglrx/README.SuSE.Unfortunately you need to recompile the "fglrx" kernel module rightafter any kernel (security) update. Use "fglrx-kernel-build.sh" for this.

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/mtnk/archive/2007/03/31/1547912.aspx

posted @ 2010-10-26 16:32 飞飞 阅读(385) | 评论 (0)编辑 收藏

     摘要: Suse Linux Enterprise Server 11.0 安装、配置与管理手册 Version 1.0 1. 安装准备 l       x86计算机,20G以上硬盘,100M以太网卡,2G以上内存; l       安装介质:SuseLinux DVD 2-1...  阅读全文
posted @ 2010-10-26 10:15 飞飞 阅读(2184) | 评论 (0)编辑 收藏

  • //接受   
  • String attachmentFile = "XXXXXXXX";    
  • //u can get correct attachment filename with this method ^&^    
  • attachmentFile = MimeUtility.decodeText(attachmentFile);    
  •   
  • //发邮件的时候这样设置附件名    
  • attachmentPart.setFileName(MimeUtility.encodeText(fds.getName()));  
  • posted @ 2010-09-01 23:36 飞飞 阅读(596) | 评论 (0)编辑 收藏

     使用java mail 包收发中文邮件的编码,解码问题以及解决方法
    JSP教程-邮件相关
    编码


    邮件头(参见RFC822,RFC2047)只能包含US-ASCII字符。邮件头中任何包含非US-ASCII字符的部分必须进行编码,使其只 包含US-ASCII字符。所以使用java mail发送中文邮件必须经过编码,否则别人收到你的邮件只能是乱码一堆。不过使用java mail 包的解决方法很简单,用它自带的MimeUtility工具中encode开头的方法(如encodeText)对中文信息进行编码就可以了。



    例子:



    MimeMessage mimeMsg = new MimeMessage(mailSession);



    //让javamail决定用什么方式来编码 ,编码内容的字符集是系统字符集mimeMsg.setSubject( MimeUtility.encodeText( Subject) );



    //使用指定的base64方式编码,并指定编码内容的字符集是gb2312

    mimeMsg.setSubject( MimeUtility.encodeText( Subject,”gb2312”,”B”));



    通常对邮件头的编码方式有2种,一种是base64方式编码,一种是QP(quoted-printable)方式编码,javamail根据具体情况来选择编码方式。



    如“txt测试”编码后内容如下:

    =?GBK?Q?Txt=B2=E2=CA=D4



    里面有个=?GBK?Q?,GBK表示的是内容的字符集,?Q?表示的是以QP方式编码的,后面紧跟的才是编码后的中文字符。所以用MimeUtility工具编码后的信息里包含了编码方式的信息。



    邮件的正文也要进行编码,但它不能用MimeUtility里的方法来编码。邮件正文的编码方式的信息是要放在Content- Transfer-Encoding这个邮件头参数中的,而MimeUtility里面的方法是将编码方式的信息放在编码后的正文内容中。所以如果你对正 文也用MimeUtility进行处理,那么其他邮件程序就不会正常显示你编码的邮件,因为其他邮件软件如outlook,foxmail只会根据 Content-Transfer-Encoding这个里面的信息来对邮件正文进行解码。



    其实,邮件正文部分的编码javamail已经自动帮你做了,当你发送邮件的时候,它会自己决定编码方式,并把编码方式的信息放入 Content-Transfer-Encoding这个邮件头参数中,然后再发送。所以你所要做的就是直接把邮件正文的内容放入邮件中就可以了。



    对邮件正文的编码方式比较多,包括了base64和QP方式,还有一些如7bit,8bit等等,因为javamail自动为邮件正文编码,所以我就不一一祥叙了。



    例子:



    //处理邮件正文

    MimeBodyPart mbp=new MimeBodyPart();



    if ( ContentType() == null || ContentType.equals(""))

    mbp.setText( Content );

    else

    mbp.setContent( Content, Content );











    解码


    javamail包中的MimeUtility工具中也提供了对邮件信息解码的方法,都是以decode开头的一些方法(如decodeText)



    例子:

    String Subject = mimemsg.getSubject();

    String ChSubject = MimeUtility.decodeText(Subject);



    对于base64和QP编码后信息,decode* 方法能将他们正确的解码,但是,如果指定的字符集不对,那么javamail就会出现错误,不能正确地将其解码。



    如有的邮件系统将”txt测试”编码后如下:

    =?x-unkown?Q?Txt=B2=E2=CA=D4



    这里指定的字符集是x-unknown,是非明确的字符集,javamail就不能正确的处理了,但是”测试”这两个中文字还是按照gbk字符集编码的,所以你可以手工的将编码方式信息改正确,再用decode*方法来解码。



    例子:

    if ( str.indexOf("=?x-unknown?") >=0 ){

    str = str.replaceAll("x-unknown","gbk" ); // 将编码方式的信息由x-unkown改为gbk

    try{

    str = MimeUtility.decodeText( str ); //再重新解码

    }catch( Exception e1){

    return str ;

    }





    decode*方法都是根据在编码信息中包含的编码方式的信息来解码,所以decode*方法对邮件正文解码是无效的,因为邮件正文中不包含编码方式的信息。



    同编码一样,邮件正文的解码也是由javamail做了。Javamail根据Content-Transfer-Encoding里的信息,来对邮件的正文解码。

    客户程序从javamail取得的正文内容字符集为iso-8859-1,所以还要将字符集转换一下,例:



    String CorrectContent = new String( Content.getbytes(“iso-8859-1”),”gb2312”);



    CorrentContent为正确的邮件正文了

    posted @ 2010-09-01 23:34 飞飞 阅读(3322) | 评论 (0)编辑 收藏

         摘要: A概念 最常用的概念 1、 scalars:存储单值 字符串:简单文本由单或双引号括起来。 数字:直接使用数值。 日期:通常从数据模型获得 布尔值:true或false,通常在<#if …>标记中使用   2、 hashes:充当其它对象的容器,每个都关联一个唯一的查询名字 具有一个唯一的查询名字和他包含的每个变量...  阅读全文
    posted @ 2010-07-03 18:09 飞飞 阅读(37451) | 评论 (4)编辑 收藏

    仅列出标题
    共12页: 上一页 1 2 3 4 5 6 7 8 9 下一页 Last