{"id":10461,"date":"2021-12-06T00:24:25","date_gmt":"2021-12-06T00:24:25","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=10461"},"modified":"2021-12-06T00:24:43","modified_gmt":"2021-12-06T00:24:43","slug":"solved-batch-text-content-to-multiple-variables","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/programming\/batch-text-content-to-multiple-variables\/30299.html","title":{"rendered":"Solved BATCH Text Content To Multiple Variables"},"content":{"rendered":"<p>Do you know a way to save the contents of a file into multiple variables in a Batch file?<\/p>\n<p>I have a file called userlist.txt containing information like:<\/p>\n<p>user1:password1<br \/>\nuser2:password2<br \/>\netc.<\/p>\n<p>and i want to save the content of that file in two variables, so i can use these variables on other commands (like automatic creation of users on a server or creation of a bash file for a linux server).<\/p>\n<p>something like this (%%u=user and %%p=password for each line):<\/p>\n<p>echo #!\/bin\/bash &gt; userStep.sh<br \/>\necho groupeadd somegroup &gt;&gt; userStep.sh<br \/>\nfor \/f &#8220;delims=&#8221; %%u %%p in (%userFile%) do (<br \/>\nmkdir z:\\users\\%%u<br \/>\nnet user %%u %%p \/add<br \/>\ncacls z:\\users\\%%u \/E \/G %%u:r<br \/>\ncacls z:\\users\\%%u \/E \/G %%u:w<br \/>\necho usereadd -d \/srv\/users\/%%u -g somegroup -N -R -s \/sbin\/nologin %%a &gt;&gt; userStep.sh<br \/>\necho echo &#8220;%%u:%%p&#8221; ^| chpasswd &gt;&gt; userStep.sh<br \/>\n)<\/p>\n<p>any help will be appreciated<\/p>\n<p align=\"right\"><span style=\"font-size: xx-small;\"><i>message edited by Atrealis<\/i><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":3},"question-category":[55],"question_tags":[],"class_list":["post-10461","question","type-question","status-publish","hentry","question-category-programming"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/10461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=10461"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=10461"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=10461"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=10461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}