![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Log command output to a file Hi all, I'm facing so much differences by running PS1 files within PowershellAnalyzer or in a PS prompt that's incredible !! I want to log a call to a command line program, I wrote: Invoke-Expression -command $run | out-file $log -encoding ASCII This works perfectly within PowershellAnalyzer, in a PS prompt, the log file is well created but remains empty. Why ?? Thanks for your help. |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Log command output to a file what does $run actually equal? without knowing what you are trying to invoke its difficult to answer the question. There seem to be a number of differences between running in Powershell Analyzer & in a PS console. I believe PA hosts a PowerShell instance so I can only suggest that the differences are due to the interaction of PA and PowerShell. It would be worth reporting this to the PowerShell Analyzer site so they can have a look at it as well -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "Romu" wrote: > Hi all, > I'm facing so much differences by running PS1 files within > PowershellAnalyzer or in a PS prompt that's incredible !! > > I want to log a call to a command line program, I wrote: > Invoke-Expression -command $run | out-file $log -encoding ASCII > > This works perfectly within PowershellAnalyzer, in a PS prompt, the log file > is well created but remains empty. Why ?? > > Thanks for your help. |
My System Specs![]() |
| | #3 (permalink) |
| Guest | RE: Log command output to a file Thanks for this answer Richard, the $run variable in this case is a call to or Starteam configuration management system. The command string looks like: stcmd hist -x -stop -nologo -p.... And when run in a PS prompt, this command sends some messages to the std output. And you're right, I'm going to warn the PSAnalyzer guys beside this thread. "RichS" wrote: > what does $run actually equal? without knowing what you are trying to invoke > its difficult to answer the question. > > There seem to be a number of differences between running in Powershell > Analyzer & in a PS console. I believe PA hosts a PowerShell instance so I > can only suggest that the differences are due to the interaction of PA and > PowerShell. It would be worth reporting this to the PowerShell Analyzer site > so they can have a look at it as well > -- > Richard Siddaway > Please note that all scripts are supplied "as is" and with no warranty > Blog: http://richardsiddaway.spaces.live.com/ > PowerShell User Group: http://www.get-psuguk.org.uk > > > "Romu" wrote: > > > Hi all, > > I'm facing so much differences by running PS1 files within > > PowershellAnalyzer or in a PS prompt that's incredible !! > > > > I want to log a call to a command line program, I wrote: > > Invoke-Expression -command $run | out-file $log -encoding ASCII > > > > This works perfectly within PowershellAnalyzer, in a PS prompt, the log file > > is well created but remains empty. Why ?? > > > > Thanks for your help. |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Log command output to a file This seems to work. May be something with what is inside $run var (maybe another redirection). PS C:\TEMP> $run = "dir" PS C:\TEMP> $log = "c:\temp\log.txt" PS C:\TEMP> invoke-expression $run | out-file $log -en ascii -- William Stacey [C# MVP] PCR concurrency library: www.codeplex.com/pcr PSH Scripts Project www.codeplex.com/psobject "Romu" <Romu@discussions.microsoft.com> wrote in message news:AAE92541-CC33-4336-B21B-B515C824C38A@microsoft.com... | Hi all, | I'm facing so much differences by running PS1 files within | PowershellAnalyzer or in a PS prompt that's incredible !! | | I want to log a call to a command line program, I wrote: | Invoke-Expression -command $run | out-file $log -encoding ASCII | | This works perfectly within PowershellAnalyzer, in a PS prompt, the log file | is well created but remains empty. Why ?? | | Thanks for your help. |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Log command output to a file In PA you use a run space. Each run space maintains its variables, functions, and settings. I would guess you keep PA all the time or at least quite a bit more than you do Posh Console. I guess my point is that it is possible that you have defined $run different in PA than in the Console. That would indeed change what is put in the file. That said... I understand the frustration. -- Brandon Shell --------------- Stop by my blog some time ![]() http://www.bsonposh.com/ Try the "Search of Powershell Blogs" -------------------------------------- "Romu" <Romu@discussions.microsoft.com> wrote in message news:AAE92541-CC33-4336-B21B-B515C824C38A@microsoft.com... > Hi all, > I'm facing so much differences by running PS1 files within > PowershellAnalyzer or in a PS prompt that's incredible !! > > I want to log a call to a command line program, I wrote: > Invoke-Expression -command $run | out-file $log -encoding ASCII > > This works perfectly within PowershellAnalyzer, in a PS prompt, the log > file > is well created but remains empty. Why ?? > > Thanks for your help. |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Log command output to a file I agree William, it works. I check. "William Stacey [C# MVP]" wrote: > This seems to work. May be something with what is inside $run var (maybe > another redirection). > > PS C:\TEMP> $run = "dir" > PS C:\TEMP> $log = "c:\temp\log.txt" > PS C:\TEMP> invoke-expression $run | out-file $log -en ascii > > -- > William Stacey [C# MVP] > PCR concurrency library: www.codeplex.com/pcr > PSH Scripts Project www.codeplex.com/psobject > > > "Romu" <Romu@discussions.microsoft.com> wrote in message > news:AAE92541-CC33-4336-B21B-B515C824C38A@microsoft.com... > | Hi all, > | I'm facing so much differences by running PS1 files within > | PowershellAnalyzer or in a PS prompt that's incredible !! > | > | I want to log a call to a command line program, I wrote: > | Invoke-Expression -command $run | out-file $log -encoding ASCII > | > | This works perfectly within PowershellAnalyzer, in a PS prompt, the log > file > | is well created but remains empty. Why ?? > | > | Thanks for your help. > > > |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: Log command output to a file i agree with brandon, this is likely the case. I can't see anyreason why powershell analyzer and powershell.exe would behave differently in this case. Mostly powershell analyzer will behave differently in cases when you are dealing with native console out, or native console in.. but for straight commands it shouldn't.. though of course if it is, i want to know. Karl http://www.powershellanalyzer.com |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: Log command output to a file Good to see you here Karl, I saw several differences between running a PS1 in PSA or PS prompt, the first one is the subject of this thread, the second one is just bere below. I wrote something like : $var = @{ 'child' = "child1" 'child2' = $var.child + "child2" } $var.child2 In PSA, the result is: child1child2 In PS prompt: child2 The PS prompt doesn't resolve variables as PSA does, I guess this could from the same thing as my $run problem. "klumsy@gmail.com" wrote: > i agree with brandon, this is likely the case. I can't see anyreason > why powershell analyzer and powershell.exe would behave differently in > this case. Mostly powershell analyzer will behave differently in cases > when you are dealing with native console out, or native console in.. > but for straight commands it shouldn't.. though of course if it is, i > want to know. > > Karl > http://www.powershellanalyzer.com > > |
My System Specs![]() |
| | #9 (permalink) |
| Guest | Re: Log command output to a file maybe a stupid question, but did you run it more than once? I sometimes forget that I have defined a variable before. Remembering that PA maintains the runspace even if you use it as IDE. When you write a script and run it... the data persist. -- Brandon Shell --------------- Stop by my blog some time ![]() http://www.bsonposh.com/ Try the "Search of Powershell Blogs" -------------------------------------- "Romu" <Romu@discussions.microsoft.com> wrote in message news:0F36ECD5-BD3C-4B6F-9F4A-2F1F9CE08D45@microsoft.com... > Good to see you here Karl, I saw several differences between running a PS1 > in > PSA or PS prompt, the first one is the subject of this thread, the second > one > is just bere below. > > I wrote something like : > > $var = @{ > 'child' = "child1" > 'child2' = $var.child + "child2" > } > > $var.child2 > > In PSA, the result is: child1child2 > In PS prompt: child2 > > The PS prompt doesn't resolve variables as PSA does, I guess this could > from > the same thing as my $run problem. > > > "klumsy@gmail.com" wrote: > >> i agree with brandon, this is likely the case. I can't see anyreason >> why powershell analyzer and powershell.exe would behave differently in >> this case. Mostly powershell analyzer will behave differently in cases >> when you are dealing with native console out, or native console in.. >> but for straight commands it shouldn't.. though of course if it is, i >> want to know. >> >> Karl >> http://www.powershellanalyzer.com >> >> |
My System Specs![]() |
| | #10 (permalink) |
| Guest | Re: Log command output to a file Yes Brandon, I run it several times, so now I know persists some variable, I'll take care. Have a look at a second interesting test in this thread, I answered my first question. And thanks for your help. "Brandon Shell" wrote: > maybe a stupid question, but did you run it more than once? > > I sometimes forget that I have defined a variable before. Remembering that > PA maintains the runspace even if you use it as IDE. When you write a script > and run it... the data persist. > > -- > Brandon Shell > --------------- > Stop by my blog some time ![]() > http://www.bsonposh.com/ > Try the "Search of Powershell Blogs" > -------------------------------------- > "Romu" <Romu@discussions.microsoft.com> wrote in message > news:0F36ECD5-BD3C-4B6F-9F4A-2F1F9CE08D45@microsoft.com... > > Good to see you here Karl, I saw several differences between running a PS1 > > in > > PSA or PS prompt, the first one is the subject of this thread, the second > > one > > is just bere below. > > > > I wrote something like : > > > > $var = @{ > > 'child' = "child1" > > 'child2' = $var.child + "child2" > > } > > > > $var.child2 > > > > In PSA, the result is: child1child2 > > In PS prompt: child2 > > > > The PS prompt doesn't resolve variables as PSA does, I guess this could > > from > > the same thing as my $run problem. > > > > > > "klumsy@gmail.com" wrote: > > > >> i agree with brandon, this is likely the case. I can't see anyreason > >> why powershell analyzer and powershell.exe would behave differently in > >> this case. Mostly powershell analyzer will behave differently in cases > >> when you are dealing with native console out, or native console in.. > >> but for straight commands it shouldn't.. though of course if it is, i > >> want to know. > >> > >> Karl > >> http://www.powershellanalyzer.com > >> > >> > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| capture command and its output | hugh | PowerShell | 1 | 02-16-2008 08:40 AM |
| Split output to command | swyck | PowerShell | 3 | 12-03-2007 03:44 PM |
| Command output to file | André Landreau | Vista file management | 3 | 11-20-2007 04:54 PM |
| How to catch a command output ? | Romu | PowerShell | 2 | 01-22-2007 09:10 AM |
| Output Event Log From Command Line | =?Utf-8?B?c2VucmFiZGV0?= | Vista General | 4 | 08-14-2006 09:23 PM |