2012年4月30日 星期一

JNI字段描述符

參見




JavaNative Interface FieldDescriptors 



在JNI里,一个类的表示,不再是使用句点来表示,而使用斜杠来表示的,比如类 java.lang.String 表示为java/lang/String的样子。
一个数组int[],就需要表示为这样"[I"。如果多个数组double[][][]就需要表示为这样 "[[[D"。也就是说每一个方括号开始,就表示一个数组维数。多个方框后面,就是数组 的类型。



字段描述符
Java语言类型
Z
boolean
B
byte
C
char
S
short
I
int
J
long
F
float
D
double




如果以一个L开头的描述符,就是类描述符,它后紧跟着类的字符串,然后分号“;”结束。
比如"Ljava/lang/String;"就是表示类型String;
"[I"就是表示int[];
"[Ljava/lang/Object;"就是表示Object[]。

JNI方法描述符,主要就是在括号里放置参数,在括号后面放置返回类型,如下:
(参数描述符)返回类型
当一个函数不需要返回参数类型时,就使用”V”来表示。
比如"()Ljava/lang/String;"就是表示Stringf();
"(ILjava/lang/Class;)J"就是表示longf(int i, Class c);
"([B)V"就是表示voidString(byte[] bytes);

perl 單行程式


http://fecbob.pixnet.net/blog/post/38616105-perl%E4%B9%8B%E5%96%AE%E8%A1%8C%E5%91%BD%E4%BB%A4%E7%89%B9%E6%8A%80

參照

---base64
編碼: perl -MMIME::Base64 -e 'print encode_base64("XXX");'
解碼: perl -MMIME::Base64 -e 'print decode_base64("XXX");'

--- iconv
perl -e 'for $file (<*.sh>){$e=`iconv -f big5 -t utf8 $file > $file.utf8`;unlink $file;rename "$file.utf8",$file;}'

--單行替換
perl -p -i.bak -e 's#/usr/IBM/#/opt/IBM/#g' *.sh

2012年4月27日 星期五

python 相關



******** python web framework
Python Web frameworks, Part 1: Develop for the Web with Django and Python

perl 各種呼叫外部程式的方式

參見

system() 會另開一個 shell

`` 會使用當下的 shell

exec() 是把當下的shell直接改成執行指定的指令

2012年4月25日 星期三

wsadmin - jython


啟動 wasadmin

/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -username ${username} -password ${password} -lang jython -profileName AppSrv01

執行 .py 檔案

/opt/IBM/WebSphere/AppServer/profiles/AppSrv01/bin/wsadmin.sh -username ${username} -password ${password} -lang jython -profileName AppSrv01 -f ${FILE}

********** 可以用的 AdminObject


*AdminConfig provides an interface to the WAS configuration repository available under profile_root/config. All AdminConfig services are provided by the Deployment Manager (assuming you're connecting remotely); there is no dependency on node agents.

*AdminControl provides an interface to JMX managed beans (MBeans) in your WAS environment. In general, MBeans are only available for the resources that are running. For example, if an application server is down, the corresponding MBean will not be available.


**********列出所有 Server

import  java.lang.System  as  sys
lineSeparator = sys.getProperty('line.separator')
jdbcps=AdminConfig.list('Server').split(lineSeparator)
for server in jdbcps:
        print "====================================================="
        print server
        print  AdminConfig.showAttribute(server,'name')
        #print  AdminConfig.showall(server)
        print "====================================================="

**********儲存變更
 AdminConfig.save()

********** Sync 另外一個 Node
import  java.lang.System  as  sys

def getAnotherNode():
    lineSeparator = sys.getProperty('line.separator')
    nodes = AdminConfig.list('Node').split(lineSeparator)
    thisnode=AdminControl.getNode()
    for node in nodes:
        nodename = AdminConfig.showAttribute(node, 'name')
        #print "PROC "+nodename
        if(nodename != thisnode):
            #print "find "+nodename
            return nodename

nodename = getAnotherNode()
Sync1=AdminControl.completeObjectName("type=NodeSync,node="+nodename+",*")
print nodename
if Sync1 != "":
AdminControl.invoke(Sync1, 'sync')

AdminConfig.save()


******************* 在 jython 檔中引入另一個 jython 檔的方式
用 execfile('C:/temp/save.py') 引入另一個檔,然後 直接 call 另一個 jython 檔中的 function

** 用 python include  的方式的話,不涉及 AdminApp, AdminConfig, AdminControl, AdminTask 元件的部分都可以正常工作。但是被引入的檔案本身看不到這些元件,所以會吐這種東西出來

NameError: AdminConfig

** 用 import 的方式似乎會當成 java 檔 compilie 成 class ?

參考

*******************參考
ServerManagement command group for the AdminTask object
Configuring servers with scripting

2012年4月24日 星期二

Linux (Redhat / Fedora / CentOS) 更改 hostname 的方式

* 改 /etc/hosts
* 改 /ets/sysconfig/network
* 用 hostname ${NewName} 再改一次

2012年4月19日 星期四

CentOS 6 ,SSH 使用 Public Key 登入

ssh-keygen -t dsa
產生  DSA key pair

id_dsa  ( Private Key )
id_dsa.pub  ( Public Key )

cd ~/.ssh
cat id_dsa.pub > authorized_keys
cat id_dsa.pub > authorized_keys2

** .ssh 本身的權限

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys2

** 有 SELinux 的話
/sbin/restorecon -R -v /home/$ACCOUNT/.ssh

參見

下載  Private Key

-- XShell
import 進 Key Manager

-- Putty
使用 PUTTYGEN.EXE 匯入
再轉成 Putty 的格式

import -> private key
save private key -> 存成 Putty 能用的 ppk 格式
然後在 putty 中指定 ppk 位置


--------------
需要把 key 送去別台 server

ssh-copy-id -i ~/.ssh/id_dsa.pub USER@HOST

*這個 script 的方向是 送出去 而不是 拉過來
*預設是用 RSA Key . 所以 DSA Key 要自己用 -i 指定 key 位置
*預設走 port 22 , 如果有改 port 要改寫 Script
*CentOS 6 以後有這個指令可以用
---------------




2012年4月10日 星期二

ESXi 密碼強度限制

http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1012033

ESX MM-Module 無回應

ESX MM-Module 無回應,SSH可以連


依據
http://communities.vmware.com/thread/50529

[ESX]
services vmware-mgmt restart
service vmware-vpxa restart

[ESXi]
/sbin/services.sh restart

如果再不行
ps -auxc | grep vmware
services vmware-mgmt stop
把看到的 vmware-watchdog , vmware-hostd 都砍掉再
services vmware-mgmt start

依據
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1003490