wsadmin将文件从本地计算机上传到远程

wsadmin将文件从本地计算机上传到远程

问题描述:

我正在尝试自动化部署过程,我想使用wsadmin(jython)将一些文件上传到WAS.我的问题是,是否可以将文件从我的独立wsadmin上载到远程WAS Server.如果是这样,是否可以将文件上传到应用程序之外的某个地方(例如/opt/IBM/WebSphere/AppServer/temp)?我不想将其上传到特定的配置文件,而是上传到服务器根目录.

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.

当我部署应用程序时,它会将war/ear文件复制到WAS,因此是否有一些机制可以上传单独的文件?

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

非常感谢

AntAgent允许您上传任何文件,只要文件的内容可以容纳在内存中即可.

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

在wsadmin中,您需要使用AdminControl对象的invoke_jmx方法.

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))

然后,您将在WAS配置文件的临时目录中找到"hello.txt"文件.您也可以使用相对路径.

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