1

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

bilak
  • 4,526
  • 3
  • 35
  • 75

1 Answers1

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.

Marcin Płonka
  • 2,840
  • 1
  • 17
  • 17
  • Marcin, thank you for your all replies. But I can't get filetransfer client. I'm trying to call it like this: AdminControl.completeObjectName('WebSphere:type=FileTransferClient,*') but it retuns nothin, resp it returns only empty quotes ''. Should I enable filetransferclient somewhere or is it only part of ND? I've got standalone server which is not part of ND. thanks – bilak Nov 08 '12 at 13:53
  • Bilak, I've added some code example of **AntAgent** and Ant script cleaning up some directories. – Marcin Płonka Nov 09 '12 at 05:44
  • working link for ibm docs AntAgent [here](https://www.ibm.com/support/knowledgecenter/SS7JFU_8.5.5/com.ibm.websphere.javadoc.doc/web/mbeanDocs/AntAgent.html) – Sunvic Feb 25 '19 at 10:22