View Single Post
Old 12-11-2006   #1 (permalink)
cccstar


 
 

Standard output and standard error merging to a log file

I am using classic ASP/vbscript and a run wscript method to call a PowerShell
command line as a quick and dirty remote terminal page. I want to redirect
the successful and unsucessful outputs of powershell commands in a my.ps1
file to an output text file that would represent a kind of one-shot session
log.

When I use verb-noun >> foo.txt inside the ps_code_file.ps1 it only seems
to capture the successful outputs in the pstemplog.txt

What method are kin to the standard error and standard out redirection in a
ksh script ?


--
FYI the magic so far looks like this:
' full-command is executed by the Wscript Shell object run method
dim full_command
full_command = "%comspec% /c """ & poweshellpath & " -NoProfile -Command
" _
& chr(34)&chr(38)&chr(39) & ps_code_file_path & chr(39) _
& ps_params & chr(34) & """ "
....
' write the command about to be run into the log file with a kludge
prompt
' "PS "+$PWD+"> "+"ps_user_command" >> pstemplog.txt
ps_code_text = chr(34) & "PS " & chr(34) & "+$PWD+" _
& chr(34) & ": " & chr(34) & "+" & chr(34) & ps_user_command &
chr(34) _
& " >> " & output_file_path
ps_code_file.writeline(ps_code_text)
' insert the command and point its output to the log
' ps_user_command >> pstemplog.txt
ps_code_text = ps_user_command & " >> " & output_file_path
ps_code_file.writeline(ps_code_text)
....
set objShell = Server.CreateObject( "WScript.Shell" )
objshell_wscript_return_value = objShell.Run(full_command, 3, true)

--
Romans 12:1-3
My System SpecsSystem Spec