1

I want something similar to printf & scanf in C in batch scripting?

This is my script

for /F "delims=;" %%i in (servers11.txt) do  (
type \\triss-s02-vm\ITG\Triton\GroupConfig.csv | grep -i %%i > temp13.txt

REM type temp.txt | gawk -F"," '{print $1}'
)

Here I am creating servers11.txt manually and entering value there. I want to enter it from command prompt. Please help me in doing that.

2 Answers 2

1

you can use SET /P to ask for user input :

set /P SERV=SERVERNAME?
echo %SERV% >> temp13.txt
Sign up to request clarification or add additional context in comments.

Comments

1

If you want to create a file from scratch on the command line, use copy con:

C:\>copy con servers11.txt
serverA
serverB
^Z
C:\>type servers11.txt
serverA
serverB
C:\>_

You end copy con by typing Ctrl+Z,Enter (the ^Z above).

2 Comments

@echo off set /p servers11.txt=Server name: for /F "delims=;" %%i in (servers11.txt) do ( type \\triss-s02-vm\ITG\Triton\GroupConfig.csv | grep -i %%i > temp13.txt ) This code is not working.. Error :- servers11.txt not found
How exactly is that related to my answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.