자이 썬 스크립팅 언어와 IBM WAS의 초보자입니다. 설치된 애플리케이션 목록 및 IBM WAS 8의 사용 포트 목록과 같은 구성 세부 사항을 알려주는 작은 스크립트를 작성하려고합니다. 스크립트를 실행하고 .txt 파일로 세부 사항을 수집하려고했습니다. 출력은 공백입니다.IBA WAS 8의 구성 세부 사항을 수집하는 자이 썬 스크립트
내 코드는 다음과 같습니다 -
#----------------------Code Starts---------------------
import sys
import string
import random
def ex2(serverName, nodeName):
#--------------------------------------------------------------
# set up globals
#--------------------------------------------------------------
global AdminConfig
global AdminTask
global AdminApp
#--------------------------------------------------------------
# do some sanity checking
# -- do we have a node by this name?
#--------------------------------------------------------------
node = AdminConfig.getid("/Node:" + nodeName + "/")
print "ex1: checking for existence of node " + nodeName
if len(node) == 0:
print "ex2: Error -- node not found for name " + nodeName
return
#--------------------------------------------------------------
# -- is a server by this name already running on the node?
#--------------------------------------------------------------
print "ex2: checking to see if server " + serverName + " is running on node " + nodeName
runningServer = AdminControl.completeObjectName("type=Server,node=" + nodeName + ",process=" + serverName + ",*")
if len(runningServer) == 0:
print "ex2: Error -- Server " + serverName + " not running on node " + nodeName
return
#--------------------------------------------------------------
# List the installed application - WAS_12
#--------------------------------------------------------------
print "List the installed application"
App_List = AdminApp.list()
my_file = open('App_List.txt','w')
my_file.write(App_List)
my_file.close()
#--------------------------------------------------------------
# Find the configuration object
#--------------------------------------------------------------
server = AdminConfig.getid("/Node:" + nodeName + "/Server:" + serverName + "/");
#--------------------------------------------------------------
# List the ports present - WAS_14
#--------------------------------------------------------------
print "List the ports"
PORT_List = AdminConfig.list("NamedEndPoint",server)
my_file = open('Port_list.txt','w')
my_file.write(PORT_List)
my_file.close()
#-----------------------------------------------------------------
# Main
#-----------------------------------------------------------------
if len(sys.argv) != 2:
print "ex2: this script requires 2 parameters: server name, node name"
print "e.g.: ex2 server2 mynode"
else:
ex2(sys.argv[0], sys.argv[1])
#-----------------Code Ends-----------------------------------------
가 나는 sample_script.py 파일에이 코드를 저장 한 나는 빈에게/ 빈의 app_server_root로 이동하여 스크립트를 실행하고>는 wsadmin -lang 자이 썬 -f 경로/에/당신의/자이 썬/sample_script.py
이 인쇄 - WASX7209I : SOAP의 CONN에게 엑터를 사용하여 노드 dbserverNode01의 "서버 1"을 처리 할 연결된; 프로세스 유형은 다음과 같습니다. UnManagedProcess
그러나 예상되는 결과는 반환되지 않습니다. 응답이 높게 평가됩니다.
서버 또는 로컬 호스트에서 출력 파일 (Port_list.txt)을 찾으십니까? 어쩌면 당신이 틀린 장소에서보고 있습니까? –