Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

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

kamit2733
kamit2733 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 Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭
    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 Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭

    kamit2733

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

  • kamit2733
    kamit2733 Posts: 16

    Hi Ireneusz

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

    Thanks

  • Ireneusz Szmigiel
    Ireneusz Szmigiel Posts: 227 ✭✭✭
    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

  • brawal
    brawal Posts: 26

    Hello There,
    I tried all the above mentioned options, however, soatest does not write out anything and keep running forever.. No error at all. What went wrong in my setting?

    Basic setting - helloworld.bat file
    soatest version 9.10 or 2022v1

    Any suggestions would be highly appreciated.