how to read name value pairs from command line

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
batchnewbie
Posts: 7
Joined: 08 Nov 2021 19:35

how to read name value pairs from command line

#1 Post by batchnewbie » 25 May 2022 01:38

Dear all,


I want to read a number of name=value pairs from the command line, how do I read them and output to a file?

Code: Select all

C:\Users\myself\read_name_value_pairs.bat log_archive_dest_1="location=R:\app\oracle\oradata\londoncdb" db_name=londoncdb
output file temporary hardcoded to temp_pfile.ora

Code: Select all

db_name=londoncdb
log_archive_dest_1="location=R:\app\oracle\oradata\londoncdb" 

batmanbatmanbatmen
Posts: 9
Joined: 23 Sep 2022 22:13

Re: how to read name value pairs from command line

#2 Post by batmanbatmanbatmen » 24 Sep 2022 03:51

Code: Select all

@echo off

:loop
set np=
if "%~1" == "" goto :eof
set np=%1
shift
set np=%np%=%1
shift
echo %np%
goto :loop
Last edited by aGerman on 24 Sep 2022 04:55, edited 1 time in total.
Reason: please use code formatting

Post Reply