I want to redirect results out to a file without leaving the wsadmin command line.
Jyhton code :
dsid = AdminConfig.getid('/DataSource:IG.JASPER.DS/')
AdminControl.testConnection(dsid)
I find something like below. but I am not sure really Can someone please let me know how to do this?
file = open("C:\\Test\\conn.txt","w")
file.write("Admin.config.... blah")
file.close()
See here for more details.
Open the file with "w" or "w+" file mode for writing to a file object.
When a file opened for write operation you can use the following :
So the below script should work for your datasource test connection
dsid = AdminConfig.getid('/DataSource:BPH Oracle XA DataSource')
status = AdminControl.testConnection(dsid)
file=open('results.txt', 'w')
#print >>file, status
#file.write(status)
file.write(AdminControl.testConnection(dsid))
file.close()
For successful connection, the generated file (results.txt) should contain an entry like "WASX7217I: Connection to provided datasource was successful."