Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to capture output during application run ?

Status
Not open for further replies.

bolobaboo

MIS
Aug 4, 2008
120
US
I am not able to capture them, any idea what changes should i do below ?

Dim WshShell
Set WshShell = WScript.CreateObject("WScript.Shell")
wshshell.currentdirectory="c:\program files\tivoli\tsm\baclient"
WshShell.Run ("dsmc macro tsm_mac.txt ")
set wshShell = Nothing
Wscript.quit(0)
 
Use the WshScriptExec object (.Exec instead of .Run) and its StdOut property.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi
I have come up following but still having hard time to capture ...i am new to VBS... can any one twik my code so i can capture all output in backup.log ?

Option Explicit
Dim objWMIService, objItem, colItems, strComputer,WshShell,outfile,TSMEXE,TSM_CMD,oExec,TSM_EXE,TSM_RUN,TSM_DIR
Dim strDriveType, strDiskSize,backup,TSM_Out_File,RC,objFS,objTextFile3,fs
Set WshShell = WScript.CreateObject("WScript.Shell")
'On Error Resume Next
strComputer = "."
wshshell.currentdirectory="c:\program files\tivoli\tsm\baclient"
TSM_Out_File = "backup.log"
Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
For Each objItem in colItems
If objItem.DriveType = 3 Then
wscript.echo objItem.Name & "\*"
backup = "sel " & objItem.Name & "\* -sub=yes"
TSM_CMD = "sel " & objItem.Name & "\* -sub=yes"
call TSM_Execute ( TSM_CMD )
End If
Next
Sub TSM_Execute ( TSM_CMD )
TSM_DIR= "c:\program files\tivoli\tsm\baclient\"
TSM_EXE = "dsmc.exe"
TSM_Run = TSM_EXE & " " & TSM_CMD
WshShell.CurrentDirectory = TSM_DIR
RC = WshShell.run(TSM_Run,1,true)
set fs=CreateObject("Scripting.FileSystemObject")
set objTextFile3 = fs.OpenTextFile(TSM_Out_File, 8, True)
objTextFile3.WriteLine(rc)
objTextFile3.Close
End Sub
WSCript.Quit(0)
 
I've suggested the Exec method, but apparently for nothing.
 
Tried below ...i am still getting type mismatch error at objTextFile3.Write objExecObject.StdOut
any idea ?

Option Explicit
Dim objWMIService, objItem, colItems, strComputer,WshShell,outfile,TSMEXE,TSM_CMD,oExec,TSM_EXE,TSM_RUN,TSM_DIR
Dim strDriveType, strDiskSize,backup,TSM_Out_File,RC,objFS,objTextFile3,fs,strText,objShell,objExecObject
Set WshShell = WScript.CreateObject("WScript.Shell")
'On Error Resume Next
strComputer = "."
wshshell.currentdirectory="c:\program files\tivoli\tsm\baclient"
TSM_Out_File = "backup.log"
Set objWMIService = GetObject ("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery ("Select * from Win32_LogicalDisk")
For Each objItem in colItems
If objItem.DriveType = 3 Then
wscript.echo objItem.Name & "\*"
TSM_CMD = "sel " & objItem.Name & "\* -sub=yes"
call TSM_Execute ( TSM_CMD )
End If
Next

Sub TSM_Execute ( TSM_CMD )
TSM_DIR= "c:\program files\tivoli\tsm\baclient\"
TSM_EXE = "dsmc.exe"
TSM_Run = TSM_EXE & " " & TSM_CMD
WshShell.CurrentDirectory = TSM_DIR
RC = WshShell.run(TSM_Run,1,true)
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec(TSM_Run)
set fs=CreateObject("Scripting.FileSystemObject")
set objTextFile3 = fs.OpenTextFile(TSM_Out_File, 8,true,-2)
objTextFile3.Write objExecObject.StdOut


objTextFile3.Close
End Sub
WSCript.Quit(0)
 
Hi
I was able to capture output.Using following ..
'
'
'
TSM_Run = TSM_EXE & " " & TSM_CMD
WshShell.CurrentDirectory = TSM_DIR
Set objShell = WScript.CreateObject("WScript.Shell")
Set objExecObject = objShell.Exec(TSM_Run)
set fs=CreateObject("Scripting.FileSystemObject")
set objTextFile3 = fs.OpenTextFile(TSM_Out_File, 8,true,-2)
objTextFile3.Write objExecObject.StdOut.readall()
'
'
Now problem is it throus out ouput once its complete.Is there way i can get output while its running application ?
 
Test the Status property of your WshScriptExec object inside a loop.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi
PHV
I am looking continous flow of output from application to a log file. Some times this application takes 1 or 2 hour to finish, so we don't want to wait that long. Instead it should start dumping out put to a log.
The one you mentioned it jsut gives whether it start or failed.

Thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top