<?xml version="1.0" encoding="iso-8859-1"?>
<rss version="2.0">
<channel>
  <title>Linux Format forums</title>
  <link>http://linuxformat.com/forums/index.php</link>
  <description>Help, discussion, magazine feedback and more</description>
  <language>english</language>
  <copyright>(c) Copyright Sat May 25, 2013 11:04 pm by Linux Format forums</copyright>
  <managingEditor>webmaster@linuxformat.com</managingEditor>
  <webMaster>webmaster@linuxformat.com</webMaster>
  <pubDate>Sat May 25, 2013 11:04 pm</pubDate>
  <lastBuildDate>Sat May 25, 2013 11:04 pm</lastBuildDate>
  <docs>http://backend.userland.com/rss</docs>
  <generator>phpBB2 RSS Syndication Mod by Lucas</generator>
  <ttl>1</ttl>

  <image>
    <title>Linux Format forums</title>
    <url></url>
    <link>http://linuxformat.com/forums/</link>
    <description>Help, discussion, magazine feedback and more</description>
  </image>

                                      <item>
                                        <title>Re: RE: hard coding keyboard input in a Bash script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=15407#15407</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=2521'&gt;drws&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Jan 11, 2006 6:22 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      &lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;CJLL wrote:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;quote&quot;&gt;Bash scripts accept upto 9 parameters on the command line, they are named $1 to $9&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Don't forget ${10} ${11} ${12} etc. if you need more than 9 parameters</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=15407#15407</comments>
                                        <author>drws</author>
                                        <pubDate>Wed Jan 11, 2006 6:22 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=15407#15407</guid>
                                      </item>
                                      <item>
                                        <title>RE: hard coding keyboard input in a Bash script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=15401#15401</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=299'&gt;TonyLB&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Wed Jan 11, 2006 3:40 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Thanks folks - I should have thought of echo!&lt;br /&gt;
&lt;br /&gt;
Neltz's one does just what I needed.&lt;br /&gt;
&lt;br /&gt;
Tony</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=15401#15401</comments>
                                        <author>TonyLB</author>
                                        <pubDate>Wed Jan 11, 2006 3:40 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=15401#15401</guid>
                                      </item>
                                      <item>
                                        <title>RE: hard coding keyboard input in a Bash script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=15372#15372</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=2007'&gt;CJLL&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jan 10, 2006 11:03 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      Bash scripts accept upto 9 parameters on the command line, they are named $1 to $9&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
echo &amp;quot;Param 1&amp;#58; $1&amp;quot;&lt;br /&gt;
&lt;br /&gt;
update-alternatives --config $1&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively if you want your script to get interactive&lt;br /&gt;
&lt;br /&gt;
&lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;&lt;br /&gt;
!/bin/sh&lt;br /&gt;
echo -n &amp;quot;Enter your name&amp;#58; &amp;quot;&lt;br /&gt;
read -e NAME&lt;br /&gt;
echo &amp;quot;Hello $NAME&amp;quot;&lt;br /&gt;
&lt;br /&gt;
update-alternatives --config $NAME&lt;br /&gt;
&lt;br /&gt;
&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=15372#15372</comments>
                                        <author>CJLL</author>
                                        <pubDate>Tue Jan 10, 2006 11:03 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=15372#15372</guid>
                                      </item>
                                      <item>
                                        <title>RE: hard coding keyboard input in a Bash script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=15343#15343</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=5'&gt;nelz&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jan 10, 2006 2:58 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      &lt;/span&gt;&lt;table width=&quot;90%&quot; cellspacing=&quot;1&quot; cellpadding=&quot;3&quot; border=&quot;0&quot; align=&quot;center&quot;&gt;&lt;tr&gt; 	  &lt;td&gt;&lt;span class=&quot;genmed&quot;&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/span&gt;&lt;/td&gt;	&lt;/tr&gt;	&lt;tr&gt;	  &lt;td class=&quot;code&quot;&gt;echo &amp;quot;xxx&amp;quot; | update-alternatives --config &amp;lt;&amp;amp;0&lt;/td&gt;	&lt;/tr&gt;&lt;/table&gt;&lt;span class=&quot;postbody&quot;&gt;&lt;br /&gt;
&lt;br /&gt;
echo sends the command to stdout&lt;br /&gt;
the pipe sends the stdout to stdin for the next command&lt;br /&gt;
&amp;amp;0 is the file handle for stdin, so &amp;lt;&amp;amp;0 redirects it to the command.</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=15343#15343</comments>
                                        <author>nelz</author>
                                        <pubDate>Tue Jan 10, 2006 2:58 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=15343#15343</guid>
                                      </item>
                                      <item>
                                        <title>hard coding keyboard input in a Bash script</title>
                                        <link>http://linuxformat.com/forums/viewtopic.php?p=15340#15340</link>
                                        <description>&lt;br /&gt;
                                      Author: &lt;a href='http://linuxformat.com/forums/profile.php?mode=viewprofile&amp;u=299'&gt;TonyLB&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;
                                      Posted: Tue Jan 10, 2006 2:45 pm&lt;br /&gt;&lt;br /&gt;
                                      &lt;br /&gt;&lt;br /&gt;
                                      I'm trying to write a couple of Bash scripts which use utility programs that take keyboard input (eg update-alternatives --config xxx needs a choice from the keyboard.&lt;br /&gt;
&lt;br /&gt;
I want to automate it from a parameter passed when the script is used.  At the moment my best effort writes a file using the input parameter, runs  update-alternatives redirecting input from the newly created file, then deletes the file.&lt;br /&gt;
&lt;br /&gt;
There must be a better way I'm sure.  How can you pass a parameter rather than use keyboard input without writing it to a file first?&lt;br /&gt;
&lt;br /&gt;
Tony</description>
                                        <comments>http://linuxformat.com/forums/viewtopic.php?p=15340#15340</comments>
                                        <author>TonyLB</author>
                                        <pubDate>Tue Jan 10, 2006 2:45 pm</pubDate>
                                        <guid isPermaLink="true">http://linuxformat.com/forums/viewtopic.php?p=15340#15340</guid>
                                      </item></channel></rss>