Is it possible to call a batch file in SOA test using Jython

kamit2733kamit2733 Posts: 16

Hi Team,

I tried to call a batch file(.bat), basically i am using the batch file to capture the logs. i have tried running a script in Jython

import os

os.system("C:\Logs\logs.bat")

the extension tool gives success but i dont see the batch file opening.

Can some one help on this issue

Thanks.

Comments

  • Ireneusz SzmigielIreneusz Szmigiel Posts: 135 ✭✭
    edited November 2017

    Hi kamit2733
    did you try to use External Tool?

    It might be easier.
    What you should to see after opening logs.bat file?
    According to python documentation:

    On Windows, the return value is that returned by the system shell after running command, given by the Windows environment variable COMSPEC: on command.com systems (Windows 95, 98 and ME) this is always 0; on cmd.exe systems (Windows NT, 2000 and XP) this is the exit status of the command run; on systems using a non-native shell, consult your shell documentation.

    Do you have access to os modules?
    On my side following script works as expected:

    Ireneusz Szmigiel

  • Ireneusz SzmigielIreneusz Szmigiel Posts: 135 ✭✭

    kamit2733

    you don't need subprocess module. In my script I have additional part which use subprocess.

  • kamit2733kamit2733 Posts: 16

    Hi Ireneusz

    Is it possible to capture the log.bat output in SOA Write File?

    Thanks

  • Ireneusz SzmigielIreneusz Szmigiel Posts: 135 ✭✭
    edited November 2017

    kamit2733

    I don't think is possible with your script. See my first comment and part from python documentation.
    You should rewrite your script to use subprocess instead of os.system.
    Or (even better), do not use bat file, just write script in Extension tool which can do the same.
    Ireneusz Szmigiel

Sign In or Register to comment.