Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista Tutorial - Encountered end of line while processing a string token

Reply
 
Old 11-15-2006   #1 (permalink)
Marco Shaw
Guest


 
 

Encountered end of line while processing a string token

I don't want to share the entire code because it is from Bruce Payette's
upcoming book.

I'd had a hard time copy and paste the code. Without sharing the whole
code, does this provide any insight as to what is wrong?

PS C:\> .\psa1.ps1
Encountered end of line while processing a string token.
At C:\psa1.ps1:5 char:5
+ @" <<<<
PS C:\> gc psa1.ps1|select-object -first 10
param($port=80)
[void][reflection.Assembly]::LoadWithPartialName("System.Net.Sockets")
function html ($content,$title = "Sample Page")
{
@"
<html>
<head>
<title>$title</title>
</head>
<body>

Since it is a function, I guess the error could also be anywhere near where
the function is called?



My System SpecsSystem Spec
Old 11-15-2006   #2 (permalink)
Marco Shaw
Guest


 
 

Re: Encountered end of line while processing a string token

> PS C:\> .\psa1.ps1
> Encountered end of line while processing a string token.
> At C:\psa1.ps1:5 char:5
> + @" <<<<


non-ASCII probably... Loaded the file with DOS/edit. I'm still having
problems though:
PS C:\> .\psa1.ps1
Incomplete 'here string' token.
At C:\psa1.ps1:5 char:5
+ @" <<<<

What's the trick to really see the content of a file and be able to pick out
non-ASCII? I tried this while 'grasping at straws':
gc psa1.ps1|out-file -encoding ascii psa2.ps1


My System SpecsSystem Spec
Old 11-15-2006   #3 (permalink)
klumsy@gmail.com
Guest


 
 

Re: Encountered end of line while processing a string token

@" and "@ and really cool in that everything between its treated
totally as literal. regardless of how many " ' ` or any other special
character... but its quite pedantic in that @" and "@ have to EACH BE
ON THEIR OWN LINE WITH NOTHING ELSE, or it will error out.... so with
that being the case

@"
hello
"@

will work, while the following 3 will not work

@"hello"@

@"hello
"@

@"
hello"@

so Marco, what company do you work for?

Karl

My System SpecsSystem Spec
Old 11-15-2006   #4 (permalink)
Marco Shaw
Guest


 
 

Re: Encountered end of line while processing a string token

<klumsy@gmail.com> wrote in message
news:1163573134.336422.83700@b28g2000cwb.googlegroups.com...
> @" and "@ and really cool in that everything between its treated
> totally as literal. regardless of how many " ' ` or any other special
> character... but its quite pedantic in that @" and "@ have to EACH BE
> ON THEIR OWN LINE WITH NOTHING ELSE, or it will error out.... so with
> that being the case


There still must be some non-ASCII in my code damn it! Maybe if I view the
file in UNIX or something! Even my ouput error seems to have non-ASCII in
it, and I can't strip it!

> so Marco, what company do you work for?


I'm assuming klumsy@gmail isn't valid... I'd prefer not to post this here
unless I was trying to promote something.

You can ask me at marcoDOTshaw@ZZZgmailDOTcom. ;-)


My System SpecsSystem Spec
Old 11-15-2006   #5 (permalink)
Andrew Watt [MVP]
Guest


 
 

Re: Encountered end of line while processing a string token

On Wed, 15 Nov 2006 01:15:57 -0400, "Marco Shaw" <marco@Znbnet.nb.ca>
wrote:

>I don't want to share the entire code because it is from Bruce Payette's
>upcoming book.
>
>I'd had a hard time copy and paste the code. Without sharing the whole
>code, does this provide any insight as to what is wrong?
>
>PS C:\> .\psa1.ps1
>Encountered end of line while processing a string token.
>At C:\psa1.ps1:5 char:5
>+ @" <<<<
>PS C:\> gc psa1.ps1|select-object -first 10
>param($port=80)
>[void][reflection.Assembly]::LoadWithPartialName("System.Net.Sockets")
>function html ($content,$title = "Sample Page")
>{
> @"


Marco,

Try it after deleting all the whitespace characters before @" on line
5.

Andrew Watt MVP
My System SpecsSystem Spec
Old 11-15-2006   #6 (permalink)
Andrew Watt [MVP]
Guest


 
 

Re: Encountered end of line while processing a string token

Marco,

Given the source of the code, perhaps it would be worth also posting
the question at http://www.manning-sandbox.com/forum.jspa?forumID=248

Andrew Watt MVP

On Wed, 15 Nov 2006 01:15:57 -0400, "Marco Shaw" <marco@Znbnet.nb.ca>
wrote:

>I don't want to share the entire code because it is from Bruce Payette's
>upcoming book.
>
>I'd had a hard time copy and paste the code. Without sharing the whole
>code, does this provide any insight as to what is wrong?
>
>PS C:\> .\psa1.ps1
>Encountered end of line while processing a string token.
>At C:\psa1.ps1:5 char:5
>+ @" <<<<
>PS C:\> gc psa1.ps1|select-object -first 10
>param($port=80)
>[void][reflection.Assembly]::LoadWithPartialName("System.Net.Sockets")
>function html ($content,$title = "Sample Page")
>{
> @"
> <html>
> <head>
> <title>$title</title>
> </head>
> <body>
>
>Since it is a function, I guess the error could also be anywhere near where
>the function is called?

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Converting Get-ChildItems to string for processing. PowerShell
do something for each token in a line separated by comma PowerShell
end of line while processing a string token issue PowerShell
Search for string in CSV and delete line if string found in line PowerShell
are there tutorial on string processing with power-shell? PowerShell


Vista Forums 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 Ltd

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