Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

| was unexpected at this time.

2,154 views
Skip to first unread message

natd...@gmail.com

unread,
Feb 9, 2007, 5:02:31 PM2/9/07
to
When I try to run this line from within a batch file

for /f "tokens=1 delims= " %%i in ('net view ^| findstr /i "%1%"') do
(set name=%%i)

I get the following error message:
| was unexpected at this time.

yet when I run from a cmd prompt it works. I'm running this on a
windows 2003 server box.

TIA

Timo Salmi

unread,
Feb 9, 2007, 6:32:21 PM2/9/07
to
natd...@gmail.com <> wrote:
> When I try to run this line from within a batch file
> for /f "tokens=1 delims= " %%i in ('net view ^| findstr /i "%1%"') do
> (set name=%%i)
>
> I get the following error message:
> | was unexpected at this time.

Your pacing is wrong. Try e.g.

for /f "tokens=1 delims= " %%i in ('
net view ^| findstr /i "%1%"') do (
set name=%%i)

Just one alternative among several correct ones.


All the best, Timo

--
Prof. Timo Salmi ftp & http://garbo.uwasa.fi/ archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:t...@uwasa.fi <http://www.uwasa.fi/~ts/> ; FIN-65101, Finland
Useful script files and tricks ftp://garbo.uwasa.fi/pc/link/tscmd.zip

Todd Vargo

unread,
Feb 9, 2007, 6:36:55 PM2/9/07
to

<natd...@gmail.com> wrote in message
news:1171058551.8...@h3g2000cwc.googlegroups.com...

Check your file again. Are you sure it has the ^ before the | as shown
above?


--
Todd Vargo
(Post questions to group only. Remove "z" to email personal messages)

billious

unread,
Feb 9, 2007, 10:44:17 PM2/9/07
to

<natd...@gmail.com> wrote in message
news:1171058551.8...@h3g2000cwc.googlegroups.com...

always post the exact source code you're using - don't retype it.

Timo's probably correct in analysing the space that you probaly have between
the caret and the pipe. The caret escapes the very next character, not the
next-significant character.

Second problem is "%1%" which should be "%1" - but this can give you strange
results, not the error of which you complain....


natd...@gmail.com

unread,
Feb 12, 2007, 10:40:21 AM2/12/07
to
On Feb 9, 7:44 pm, "billious" <billious_1...@hotmail.com> wrote:
> <natda...@gmail.com> wrote in message

It turns out it was the second problem "%1%", when I changed that to
"%1" the problem was resolved.

Thanks for all the suggestions.

0 new messages