[Resolved]Capturing EXEC output

User discussion and information resource forum for scripting of TeraByte products using script lanugages such as TBScript, VBScript, Batch Files, and more.
Post Reply
nemesis
Posts: 76
Joined: Mon Jun 21, 2021 12:25 pm

[Resolved]Capturing EXEC output

Post by nemesis »

Hi,

as the title says I want to capture the output os a command run with EXEC in a tbsscript for obvious reasons.

How would i go about this?

Regards,

Davy
Last edited by nemesis on Fri Aug 27, 2021 8:28 am, edited 1 time in total.
TeraByte Support(PP)
Posts: 1643
Joined: Fri Aug 12, 2011 12:51 am

Re: Capturing EXEC output

Post by TeraByte Support(PP) »

If you can redirect to a file you could read that back in and process it. For example, 'dir' output:

Code: Select all

sub main()
  r = exec("cmd.exe /c dir >dirout.txt",1)
  printl("^n^nResult code: " # r)

  printl("^n^n-----------------------")
  printl("Contents of dirout.txt:")
  printl("-----------------------")
  f = open("dirout.txt", "uin")
  s = readl(f)
  while (s<>"")
    print(s)
    s=readl(f)
  wend
  close(f)

end sub
nemesis
Posts: 76
Joined: Mon Jun 21, 2021 12:25 pm

Re: Capturing EXEC output

Post by nemesis »

Hi Paul,

not the most elegant solution but it'll serve my purposes, thnx.
Post Reply