Want to Run OS Commands From WLST?
        Posted  
        
            by Bala Kothandaraman
        on Oracle Blogs
        
        See other posts from Oracle Blogs
        
            or by Bala Kothandaraman
        
        
        
        Published on Thu, 17 Jun 2010 09:06:35 -0500
        Indexed on 
            2010/06/17
            14:24 UTC
        
        
        Read the original article
        Hit count: 607
        
Admin Topics
|WLST
If you spend a lot of time with WLST in the interactive mode, I am sure you have opened another command prompt/shell to check something at the OS file system level. If you wonder whether can execute an OS command from within WLST prompt, the answer is "Yes". This is very convenient similar to how you can execute OS commands from within "Vi" editor.
In fact this feature is not from WLST but from underlying Jython. There is "os" module in Jython that provides a unified interface to a number of operating system functions. There is "system" function in the "os" module that can take a OS command as a string input and returns either "0" or "1" depends on whether the command was successful or failed. So this feature can also be used with scripting mode where the return code can be verified for further processing in the script.
For eg. os.system(r'dir c:\bea') can list the contents of the bea folder under c drive. Notice the use of the preceding 'r' for escaping the entire string.
© Oracle Blogs or respective owner
