Capture shell command output

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • sdfsf93924554234fjfjf
    Indigo Rose Customer
    • Mar 2007
    • 19

    Capture shell command output

    Hi, does anyone know if its possible to execute an external shell command (I beleive this is possible) and capture the output of that command into a text buffer for future action?

    I know this kind of thing is possible in other scripting languages (Perl, Python etc). But I can't see how to do the same thing in AMS 7.0

    Any pointers appreciated.

    Cheers

    Chris
  • Ulrich
    Indigo Rose Staff Member
    • Apr 2005
    • 5130

    #2
    If you are calling a console application, you should be able to redirect the output to a text file, and read it back in AMS. For example:

    Code:
    res = File.Run("C:\\WINDOWS\\SYSTEM32\\CMD.EXE", "/C chkdsk C: >output.txt", "D:\\TEMP", SW_SHOWNORMAL, true);
    This will fire up the checkdisk utility, and output all text normally displayed to a text file "output.txt", located in the D:\TEMP folder. All you have to do is read this file now, for whatever purpose... and then delete the file when you don't need it any more.

    Cheers,
    Ulrich

    Comment

    Working...
    X