<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Linux script to prompt for password</title> <atom:link href="http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Mmm</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-67235</link> <dc:creator>Mmm</dc:creator> <pubDate>Fri, 20 Jan 2012 04:37:07 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-67235</guid> <description>hi guys,
if in the middle of execution of script ,
some process asked for some input from keyboard . How can i provide that input from the script?</description> <content:encoded><![CDATA[<p>hi guys,<br
/> if in the middle of execution of script ,<br
/> some process asked for some input from keyboard . How can i provide that input from the script?</p> ]]></content:encoded> </item> <item><title>By: rem</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-64001</link> <dc:creator>rem</dc:creator> <pubDate>Tue, 01 Nov 2011 15:55:56 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-64001</guid> <description>Hi Vivek,
How to make a one liner that can implement the prompt script to run multiple times?
eg. the simplest one i can think of:
i have one user list, name it as userlist.txt with content as below:
mary:mary@mail.com
kent:kent@mail.com
judy:judy@mail.com
......
with a script that used to reset single user password, resetpwd.sh
#!/bin/bash
user=$1
read -p &quot;reset user password (y/n)&quot; yn
case $yn in
y&#124;Y)
echo &quot;plsresetlater&quot; &#124; passwd --stdin $user &amp;&gt; /dev/null;;
n&#124;N)
echo &quot;user password did not change&quot;;;
esac
then run the one liner by piping all the username to the resetpwd.sh; see output:
reset user password (y/n) y #user mary
reset user password (y/n) n #user kent
user password did not change
reset user password (y/n) n #user judy
user password did not change
......
i have tried the awk; not working
awk -F &quot;:&quot; &#039;{print $1}&#039; userlist.txt &#124;  while read users; do resetpwd.sh $users; done</description> <content:encoded><![CDATA[<p>Hi Vivek,</p><p>How to make a one liner that can implement the prompt script to run multiple times?<br
/> eg. the simplest one i can think of:</p><p>i have one user list, name it as userlist.txt with content as below:<br
/> mary:mary@mail.com<br
/> kent:kent@mail.com<br
/> judy:judy@mail.com<br
/> &#8230;&#8230;</p><p>with a script that used to reset single user password, resetpwd.sh<br
/> #!/bin/bash</p><p>user=$1</p><p>read -p &#8220;reset user password (y/n)&#8221; yn</p><p>case $yn in<br
/> y|Y)<br
/> echo &#8220;plsresetlater&#8221; | passwd &#8211;stdin $user &amp;&gt; /dev/null;;<br
/> n|N)<br
/> echo &#8220;user password did not change&#8221;;;<br
/> esac</p><p>then run the one liner by piping all the username to the resetpwd.sh; see output:</p><p>reset user password (y/n) y #user mary<br
/> reset user password (y/n) n #user kent<br
/> user password did not change<br
/> reset user password (y/n) n #user judy<br
/> user password did not change<br
/> &#8230;&#8230;</p><p>i have tried the awk; not working<br
/> awk -F &#8220;:&#8221; &#8216;{print $1}&#8217; userlist.txt |  while read users; do resetpwd.sh $users; done</p> ]]></content:encoded> </item> <item><title>By: Josu</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-59650</link> <dc:creator>Josu</dc:creator> <pubDate>Fri, 27 May 2011 11:11:27 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-59650</guid> <description>Thank for this post, very interesting.</description> <content:encoded><![CDATA[<p>Thank for this post, very interesting.</p> ]]></content:encoded> </item> <item><title>By: beta</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-56322</link> <dc:creator>beta</dc:creator> <pubDate>Tue, 15 Mar 2011 04:48:44 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-56322</guid> <description>Unfortunately, read -s only works if the first line of your script sets the shell to bash.  Tested in ubuntu.
IF THIS does work
#!/bin/sh
set to
#!/bin/bash</description> <content:encoded><![CDATA[<p>Unfortunately, read -s only works if the first line of your script sets the shell to bash.  Tested in ubuntu.</p><p>IF THIS does work<br
/> #!/bin/sh</p><p>set to<br
/> #!/bin/bash</p> ]]></content:encoded> </item> <item><title>By: Tukur Dan-Asabe</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-1088</link> <dc:creator>Tukur Dan-Asabe</dc:creator> <pubDate>Thu, 19 Oct 2006 08:58:16 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-1088</guid> <description>Thanks nixcraft,</description> <content:encoded><![CDATA[<p>Thanks nixcraft,</p> ]]></content:encoded> </item> <item><title>By: nixcraft</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-106</link> <dc:creator>nixcraft</dc:creator> <pubDate>Tue, 12 Sep 2006 14:13:18 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-106</guid> <description>Tukur,
Assuming that your file.txt is as follows:
val1   val2   val3
Here is a shell script:
&lt;b&gt;
#!/bin/sh
while read line
do
# store field 1
F1=$(echo $line&#124;cut -d&quot; &quot; -f1)
# store field 2
F2=$(echo $line&#124;cut -d&quot; &quot; -f2)
# store field
F3=$(echo $line&#124;cut -d&quot; &quot; -f3)
echo $F1 &quot; &quot; $F2 &quot; &quot; $F3
done &lt; file.txt
&lt;/b&gt;
Var $F1 $F2 and $F3 stores the value. If you need more help try out shell scripting forum @ http://forum.cyberciti.biz/</description> <content:encoded><![CDATA[<p>Tukur,</p><p>Assuming that your file.txt is as follows:<br
/> val1   val2   val3</p><p>Here is a shell script:<br
/> <b><br
/> #!/bin/sh<br
/> while read line<br
/> do<br
/> # store field 1<br
/> F1=$(echo $line|cut -d&#8221; &#8221; -f1)<br
/> # store field 2<br
/> F2=$(echo $line|cut -d&#8221; &#8221; -f2)<br
/> # store field<br
/> F3=$(echo $line|cut -d&#8221; &#8221; -f3)<br
/> echo $F1 &#8221; &#8221; $F2 &#8221; &#8221; $F3<br
/> done < file.txt<br
/> </b></p><p>Var $F1 $F2 and $F3 stores the value. If you need more help try out shell scripting forum @ <a
href="http://forum.cyberciti.biz/" rel="nofollow">http://forum.cyberciti.biz/</a></b></p> ]]></content:encoded> </item> <item><title>By: Tukur Dan-Asabe</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-102</link> <dc:creator>Tukur Dan-Asabe</dc:creator> <pubDate>Tue, 12 Sep 2006 08:28:17 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-102</guid> <description>Please I want to y1, y2 and y3 to have values piped in by the pipe (&#124;) and read to read from the file and asign them to the variables but
export tukur=2
test is a file contain 3 columns say: aa bb cc
after excuting the following command y1, y2, y3 dont contain anythin pls could someone help?
tail -n +$tukur home/tukur/test &#124; read -r y1 y2 y3
Thank you,
Tukur Dan-Asabe.</description> <content:encoded><![CDATA[<p>Please I want to y1, y2 and y3 to have values piped in by the pipe (|) and read to read from the file and asign them to the variables but</p><p>export tukur=2<br
/> test is a file contain 3 columns say: aa bb cc<br
/> after excuting the following command y1, y2, y3 dont contain anythin pls could someone help?</p><p>tail -n +$tukur home/tukur/test | read -r y1 y2 y3</p><p>Thank you,<br
/> Tukur Dan-Asabe.</p> ]]></content:encoded> </item> <item><title>By: Dave</title><link>http://www.cyberciti.biz/faq/linux-script-to-prompt-for-password/#comment-17</link> <dc:creator>Dave</dc:creator> <pubDate>Thu, 17 Aug 2006 02:19:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/linux-script-to-prompt-for-password.php#comment-17</guid> <description>Thanks!</description> <content:encoded><![CDATA[<p>Thanks!</p> ]]></content:encoded> </item> </channel> </rss>
