【问题标题】:Write to the file output of wsadmin scripting写入 wsadmin 脚本的文件输出
【发布时间】:2019-03-16 23:17:40
【问题描述】:

我想在不离开 wsadmin 命令行的情况下将结果重定向到一个文件。

Jyhton 代码:

dsid = AdminConfig.getid('/DataSource:IG.JASPER.DS/')
AdminControl.testConnection(dsid)

我在下面找到了类似的东西。但我不确定真的有人可以告诉我该怎么做吗?

file = open("C:\\Test\\conn.txt","w")
file.write("Admin.config.... blah") 
file.close()

【问题讨论】:

    标签: python websphere jython wsadmin


    【解决方案1】:

    更多详情请见here

    使用“w”或“w+”文件模式打开文件以写入文件对象。
    当打开文件进行写操作时,您可以使用以下内容:

    • 重定向运算符>>
    • 写函数
    • 写线函数

    所以下面的脚本应该适用于您的数据源测试连接

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

    为了成功连接,生成的文件 (results.txt) 应包含类似“WASX7217I: Connection to provided datasource is successful.”的条目。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-22
      • 1970-01-01
      • 2017-01-09
      • 1970-01-01
      • 1970-01-01
      • 2014-09-02
      • 1970-01-01
      相关资源
      最近更新 更多