wsadmin upload file from local machine to remote

被刻印的时光 ゝ 提交于 2019-12-11 09:56:28

问题


I'm trying to automate process of deployment and I want to upload some files to WAS using wsadmin (jython). My question is if it is possible to upload file from my standalone wsadmin to remote WAS Server. And if so, is it possible to upload file somewhere out of application (fe. /opt/IBM/WebSphere/AppServer/temp)? I don't want to upload it to specific profile, but to server root.

When I'm deploying application it is copying war/ear file to WAS, so is it there some mechani to upload separate file?

many thanks


回答1:


AntAgent allows you to upload any file, provided that the content of the file can fit in memory:

https://www.ibm.com/support/knowledgecenter/en/SSAW57_8.5.5/com.ibm.websphere.javadoc.doc/web/mbeanDocs/AntAgent.html

In wsadmin you'll need to use invoke_jmx method of AdminControl object.

from java.lang import String
import jarray

fileContent = 'hello!'
antAgent = AdminControl.makeObjectName(AdminControl.queryNames('WebSphere:*,type=AntAgent,process=dmgr'))

str = String(fileContent)
bytes = str.getBytes()

AdminControl.invoke_jmx(antAgent, 'putScript', [String('hello.txt'),bytes], jarray.array(['java.lang.String', '[B'], String))

Afterwards you'll find 'hello.txt' file in WAS profile's temp directory. You may use relative paths as well.



来源:https://stackoverflow.com/questions/13266486/wsadmin-upload-file-from-local-machine-to-remote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!