- PR -

stdin ?

1
投稿者投稿内容
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-08-16 16:26
コード:

set /p inputline=


can be used just one line stdin.
how about multiple line input?
does W2k have a full fledged stdin?
yamachan
会議室デビュー日: 2001/08/02
投稿数: 18
お住まい・勤務地: 東京に生息
投稿日時: 2001-08-17 16:15
Hi Oregon,

Basically, I use a temporary file to input multi-line. Like;

copy con temp.file

It's not beautiful, and expect users to input "^Z". :-P

So, how about the following code? It's too simple - can't handle a space & a empty line. :-)

---------------------------------
@echo off
set boo=
:LOOP
set foo=
set/p foo=
set boo=%boo% %foo%
if defined foo goto LOOP

for %%v in (%boo%) do echo %%v
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-08-19 04:28
hmmmm...
ctrl-Z for end of file is norm and fine.
but there are problematic behaviors:
1. no pipe - I need "something | this.bat"
2. a blank line causes end of input
(before ctrl-Z gets caught)
3. glitches special characters
(fun to watch ! & * ^ ...)
4. space separated input makes multiple lines a word

they are are important to me in that order.

yr idea of "copy con..." lead me to think;
using other fileters - 'more' !

@echo off
set buff=%temp%\%~n0%random%%random%.tmp
more >> %buff%
type %buff%
del %buff%
set buff=

it satisfies all 4 items above.

now let's try an easy one-liner - 'tee'

@del/f %~1 2>nul & more >> %~1


how about other filters like 'sed'?
Oregon
ベテラン
会議室デビュー日: 2001/08/01
投稿数: 52
お住まい・勤務地: Tualatin 97062
投稿日時: 2001-08-26 07:35
"tee" one-liner should rather read:
コード:

@del/f "%1" 2>nul & more >> "%1" & type "%1"



and "sed" stuff will appear in a new thread.
1

スキルアップ/キャリアアップ(JOB@IT)