Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

select-string bug with large files

Closed Thread
 
Thread Tools Display Modes
Old 12-01-2006   #1 (permalink)
Keith Hill [MVP]
Guest


 

select-string bug with large files

I think Select-String might have a bug dealing directly with large files:

7> ss "^\d+>" 20061130.112925.5360.txt
Select-String : The file can not be read: C:\Documents and Settings\hillr\My
Do
cuments\WindowsPowerShell\Transcripts\20061130.112925.5360.txt
At line:1 char:3
+ ss <<<< "^\d+>" 20061130.112925.5360.txt
[C:\Documents and Settings\hillr\My Documents\WindowsPowerShell\Transcripts]
8> gc 20061130.112925.5360.txt | ss "^\d+>"

1> cd \bin
2> e Convert-TfvcStatusObject.ps1
3> gcm new-*
4> e New-GenericObject.ps1
....

Should I bug this or is this expected behavior? The file in question is
about 663 KB in size.

--
Keith


Old 12-02-2006   #2 (permalink)
Andrew Watt [MVP]
Guest


 

Re: select-string bug with large files

Keith,

I'm able to run commands like
select-string "\d" -path 20061101203124.txt
a file which is ~900kb

Just a thought ... ... are you getting the error message because
the PowerShell console is still holding the transcript file open? I
notice that the console was opened only a day ago.

I can get your error message reproducibly if I open a console (which
has start-transcript in the profile) but when I close the console the
select-string command works.

Andrew Watt MVP

On Fri, 1 Dec 2006 21:49:31 -0700, "Keith Hill [MVP]"
<r_keith_hill@no.spam.thank.u.hotmail.com> wrote:

>I think Select-String might have a bug dealing directly with large files:
>
>7> ss "^\d+>" 20061130.112925.5360.txt
>Select-String : The file can not be read: C:\Documents and Settings\hillr\My
>Do
>cuments\WindowsPowerShell\Transcripts\20061130.112925.5360.txt
>At line:1 char:3
>+ ss <<<< "^\d+>" 20061130.112925.5360.txt
>[C:\Documents and Settings\hillr\My Documents\WindowsPowerShell\Transcripts]
>8> gc 20061130.112925.5360.txt | ss "^\d+>"
>
>1> cd \bin
>2> e Convert-TfvcStatusObject.ps1
>3> gcm new-*
>4> e New-GenericObject.ps1
>...
>
>Should I bug this or is this expected behavior? The file in question is
>about 663 KB in size.
>
>--
>Keith

Old 12-02-2006   #3 (permalink)
dreeschkind
Guest


 

Re: select-string bug with large files

Still, this does not answer the question why Get-Content | Select-String
works, but Select-String does not.

--
greetings
dreeschkind

"Andrew Watt [MVP]" wrote:

> Keith,
>
> I'm able to run commands like
> select-string "\d" -path 20061101203124.txt
> a file which is ~900kb
>
> Just a thought ... ... are you getting the error message because
> the PowerShell console is still holding the transcript file open? I
> notice that the console was opened only a day ago.
>
> I can get your error message reproducibly if I open a console (which
> has start-transcript in the profile) but when I close the console the
> select-string command works.
>
> Andrew Watt MVP
>
> On Fri, 1 Dec 2006 21:49:31 -0700, "Keith Hill [MVP]"
> <r_keith_hill@no.spam.thank.u.hotmail.com> wrote:
>
> >I think Select-String might have a bug dealing directly with large files:
> >
> >7> ss "^\d+>" 20061130.112925.5360.txt
> >Select-String : The file can not be read: C:\Documents and Settings\hillr\My
> >Do
> >cuments\WindowsPowerShell\Transcripts\20061130.112925.5360.txt
> >At line:1 char:3
> >+ ss <<<< "^\d+>" 20061130.112925.5360.txt
> >[C:\Documents and Settings\hillr\My Documents\WindowsPowerShell\Transcripts]
> >8> gc 20061130.112925.5360.txt | ss "^\d+>"
> >
> >1> cd \bin
> >2> e Convert-TfvcStatusObject.ps1
> >3> gcm new-*
> >4> e New-GenericObject.ps1
> >...
> >
> >Should I bug this or is this expected behavior? The file in question is
> >about 663 KB in size.
> >
> >--
> >Keith

>

Old 12-02-2006   #4 (permalink)
Keith Hill [MVP]
Guest


 

Re: select-string bug with large files

"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:1gk2n218she7o9q7ulo3vgqs73doc0dmsk@4ax.com...
> I'm able to run commands like
> select-string "\d" -path 20061101203124.txt
> a file which is ~900kb
>
> Just a thought ... ... are you getting the error message because
> the PowerShell console is still holding the transcript file open? I
> notice that the console was opened only a day ago.
>
> I can get your error message reproducibly if I open a console (which
> has start-transcript in the profile) but when I close the console the
> select-string command works.


Yeah that is possible. I was getting that error on two large transcript
files which could have corresponded to the two consoles I had open. Perhaps
the get-content worked because of a timing issue???

--
Keith


Old 12-04-2006   #5 (permalink)
Andrew Watt [MVP]
Guest


 

Re: select-string bug with large files

On my machine it does.

get-content can access the content of a transcript file despite the
console corresponding to the transcript file still being open. That
would fit with the explanation I suggested to Keith.

I assume that select-string and get-content open a file in different
ways.

Maybe Jeffrey or someone with more knowledge of the internals can help
us figure out the exact difference.

Andrew Watt MVP

On Sat, 2 Dec 2006 06:00:01 -0800, dreeschkind
<dreeschkind@discussions.microsoft.com> wrote:

>Still, this does not answer the question why Get-Content | Select-String
>works, but Select-String does not.
>
>--
>greetings
>dreeschkind
>
>"Andrew Watt [MVP]" wrote:
>
>> Keith,
>>
>> I'm able to run commands like
>> select-string "\d" -path 20061101203124.txt
>> a file which is ~900kb
>>
>> Just a thought ... ... are you getting the error message because
>> the PowerShell console is still holding the transcript file open? I
>> notice that the console was opened only a day ago.
>>
>> I can get your error message reproducibly if I open a console (which
>> has start-transcript in the profile) but when I close the console the
>> select-string command works.
>>
>> Andrew Watt MVP
>>
>> On Fri, 1 Dec 2006 21:49:31 -0700, "Keith Hill [MVP]"
>> <r_keith_hill@no.spam.thank.u.hotmail.com> wrote:
>>
>> >I think Select-String might have a bug dealing directly with large files:
>> >
>> >7> ss "^\d+>" 20061130.112925.5360.txt
>> >Select-String : The file can not be read: C:\Documents and Settings\hillr\My
>> >Do
>> >cuments\WindowsPowerShell\Transcripts\20061130.112925.5360.txt
>> >At line:1 char:3
>> >+ ss <<<< "^\d+>" 20061130.112925.5360.txt
>> >[C:\Documents and Settings\hillr\My Documents\WindowsPowerShell\Transcripts]
>> >8> gc 20061130.112925.5360.txt | ss "^\d+>"
>> >
>> >1> cd \bin
>> >2> e Convert-TfvcStatusObject.ps1
>> >3> gcm new-*
>> >4> e New-GenericObject.ps1
>> >...
>> >
>> >Should I bug this or is this expected behavior? The file in question is
>> >about 663 KB in size.
>> >
>> >--
>> >Keith

>>

Old 12-04-2006   #6 (permalink)
Lee Holmes [MSFT]
Guest


 

Re: select-string bug with large files

This is a correct conclusion (as SysInternals' FileMon / Process Explorer
show when you examine the way that PowerShell opens files in these
situations.)

The Get-Content cmdlet opens the files with a file sharing mode of ReadWrite
(which allows readers and a writer at the same time,) while the
Select-String cmdlet only opens them with a sharing mode of Read (which
allows only readers.)

Keith; could you file a bug for this?

--
Lee Holmes [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

"Andrew Watt [MVP]" <SVGDeveloper@aol.com> wrote in message
news:hvf8n2du6pu0msi54lt98838sa40944n8t@4ax.com...
> On my machine it does.
>
> get-content can access the content of a transcript file despite the
> console corresponding to the transcript file still being open. That
> would fit with the explanation I suggested to Keith.
>
> I assume that select-string and get-content open a file in different
> ways.
>
> Maybe Jeffrey or someone with more knowledge of the internals can help
> us figure out the exact difference.
>
> Andrew Watt MVP
>
> On Sat, 2 Dec 2006 06:00:01 -0800, dreeschkind
> <dreeschkind@discussions.microsoft.com> wrote:
>
>>Still, this does not answer the question why Get-Content | Select-String
>>works, but Select-String does not.
>>
>>--
>>greetings
>>dreeschkind
>>
>>"Andrew Watt [MVP]" wrote:
>>
>>> Keith,
>>>
>>> I'm able to run commands like
>>> select-string "\d" -path 20061101203124.txt
>>> a file which is ~900kb
>>>
>>> Just a thought ... ... are you getting the error message because
>>> the PowerShell console is still holding the transcript file open? I
>>> notice that the console was opened only a day ago.
>>>
>>> I can get your error message reproducibly if I open a console (which
>>> has start-transcript in the profile) but when I close the console the
>>> select-string command works.
>>>
>>> Andrew Watt MVP
>>>
>>> On Fri, 1 Dec 2006 21:49:31 -0700, "Keith Hill [MVP]"
>>> <r_keith_hill@no.spam.thank.u.hotmail.com> wrote:
>>>
>>> >I think Select-String might have a bug dealing directly with large
>>> >files:
>>> >
>>> >7> ss "^\d+>" 20061130.112925.5360.txt
>>> >Select-String : The file can not be read: C:\Documents and
>>> >Settings\hillr\My
>>> >Do
>>> >cuments\WindowsPowerShell\Transcripts\20061130.112925.5360.txt
>>> >At line:1 char:3
>>> >+ ss <<<< "^\d+>" 20061130.112925.5360.txt
>>> >[C:\Documents and Settings\hillr\My
>>> >Documents\WindowsPowerShell\Transcripts]
>>> >8> gc 20061130.112925.5360.txt | ss "^\d+>"
>>> >
>>> >1> cd \bin
>>> >2> e Convert-TfvcStatusObject.ps1
>>> >3> gcm new-*
>>> >4> e New-GenericObject.ps1
>>> >...
>>> >
>>> >Should I bug this or is this expected behavior? The file in question
>>> >is
>>> >about 663 KB in size.
>>> >
>>> >--
>>> >Keith
>>>



Old 12-04-2006   #7 (permalink)
Keith Hill [MVP]
Guest


 

Re: select-string bug with large files

"Lee Holmes [MSFT]" <lee.holmes@online.microsoft.com> wrote in message
news:eoC$5M8FHHA.3464@TK2MSFTNGP05.phx.gbl...
> This is a correct conclusion (as SysInternals' FileMon / Process Explorer
> show when you examine the way that PowerShell opens files in these
> situations.)
>
> The Get-Content cmdlet opens the files with a file sharing mode of
> ReadWrite (which allows readers and a writer at the same time,) while the
> Select-String cmdlet only opens them with a sharing mode of Read (which
> allows only readers.)
>
> Keith; could you file a bug for this?


Done.

https://connect.microsoft.com/feedba...3045&SiteID=99

--
Keith


Old 12-04-2006   #8 (permalink)
William Stacey [C# MVP]
Guest


 

Re: select-string bug with large files

How about a cmdlet for filing and viewing bugs on Connect? After all, were
are in a console when we find an issue - no?

--
William Stacey [C# MVP]

"Keith Hill [MVP]" <r_keith_hill@no.spam.thank.u.hotmail.com> wrote in
message news:%23N2odX8FHHA.1188@TK2MSFTNGP06.phx.gbl...
| "Lee Holmes [MSFT]" <lee.holmes@online.microsoft.com> wrote in message
| news:eoC$5M8FHHA.3464@TK2MSFTNGP05.phx.gbl...
| > This is a correct conclusion (as SysInternals' FileMon / Process
Explorer
| > show when you examine the way that PowerShell opens files in these
| > situations.)
| >
| > The Get-Content cmdlet opens the files with a file sharing mode of
| > ReadWrite (which allows readers and a writer at the same time,) while
the
| > Select-String cmdlet only opens them with a sharing mode of Read (which
| > allows only readers.)
| >
| > Keith; could you file a bug for this?
|
| Done.
|
|
https://connect.microsoft.com/feedba...3045&SiteID=99
|
| --
| Keith
|
|


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Select-String search in-use files? Chris Harris PowerShell 0 05-01-2008 11:00 AM
Re: logfile select-string Kiron PowerShell 0 04-04-2008 03:47 PM
problems with $var | select-string -pattern $string -q Ben Christian PowerShell 3 02-08-2008 12:41 PM
Re: select-string exceptions cmyers PowerShell 0 05-23-2007 02:09 PM
Re: select-string exceptions cmyers PowerShell 0 05-23-2007 02:09 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50