<?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: Shell Script to get user input</title>
	<atom:link href="http://www.thelinuxblog.com/shell-script-get-user-input/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.thelinuxblog.com/shell-script-get-user-input/</link>
	<description>The Linux Blog, General Linux, Shell Scripts</description>
	<lastBuildDate>Fri, 03 Feb 2012 06:36:29 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: The Linux Blog &#187; 2010 Statistics</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-5982</link>
		<dc:creator>The Linux Blog &#187; 2010 Statistics</dc:creator>
		<pubDate>Wed, 05 Jan 2011 10:32:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-5982</guid>
		<description>[...] Posts of 2010 1) Shell Script To Get User Input 2) iPhone SSH Client 3) Using Cut Shellscript String Manipulation 4) rsync to smb share 5) [...]</description>
		<content:encoded><![CDATA[<p>[...] Posts of 2010 1) Shell Script To Get User Input 2) iPhone SSH Client 3) Using Cut Shellscript String Manipulation 4) rsync to smb share 5) [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CaliDude</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-4678</link>
		<dc:creator>CaliDude</dc:creator>
		<pubDate>Tue, 14 Dec 2010 14:32:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-4678</guid>
		<description>Thanks!!!! I this script but the part im missing is how to get the variables correctly so that when ready I can just input the name and the last octet of the ip address

#!/bin/bash

# Get next available IP (loop through subnet and find first IP that doesn&#039;t respond to ping)
IP=$(for i in `seq 1 254`; do if (! ping -q -c 1 192.168.0.{i} 1&gt;/dev/null 2&gt;&amp;1); then echo ${i}; break; fi; done)

# Delete current IP address from config file
sed &#039;/IPADDR/d&#039; /etc/sysconfig/network-scripts/ifcfg-bond0 &gt; /etc/sysconfig/network-scripts/ifcfg-bond0.new

# Add configuration option for new IP address
echo &quot;IPADDR=192.168.1.${IP}&quot; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-bond0.new

# Replace network interface configuration
mv /etc/sysconfig/network-scripts/ifcfg-bond0.new /etc/sysconfig/network-scripts/ifcfg-bond0

# Same with hostname
sed &#039;/HOSTNAME/d&#039; /etc/sysconfig/network &gt; /etc/sysconfig/network.new
echo &quot;HOSTNAME=newhostname&quot; &gt;&gt; /etc/sysconfig/network.new
mv /etc/sysconfig/network /etc/sysconfig/network

echo &quot;Reboot for changes to take effect...&quot; 

im kinda new to the bash scripting world so im kinda in the mud with this and your help would again be awesome!!

But I think my script is a little off my counterpart got this working in windows but he cant help with stuff Linux stuff 

this is what he made


[int]$a = read-host -Prompt &quot;input CDS number&quot;
      
      if($a -lt 240 -and $a -gt 0){
          #  baspscfg -name 247Team -type 2
          if($a -lt 10){
                $hostname = &quot;de-cds-win-0$a&quot;
            }
            else{
                $hostname = &quot;de-cds-win-$a&quot;
            }
                $ip = &quot;10.8.40.$($a + 10)&quot;
                Write-Host &quot;ip-adress $ip&quot;
                #  netsh interface ip set address name=&quot;247Team&quot; static $ip 10.8.40.1 255.255.255.0. 1
                #  netsh interface dns set address name=&quot;247Team&quot; static 10.1.14.35
                $computerinfo = Get-WmiObject -class win32_computersystem
                #$computerinfo.Rename($hostname)
                Write-Host &quot;changed from $computerinfo to $NewComputerName&quot;
            
      }
      else{
            write-host &quot;if the server number is over 240 you will have to enter them your self enjoy&quot;
      }</description>
		<content:encoded><![CDATA[<p>Thanks!!!! I this script but the part im missing is how to get the variables correctly so that when ready I can just input the name and the last octet of the ip address</p>
<p>#!/bin/bash</p>
<p># Get next available IP (loop through subnet and find first IP that doesn&#8217;t respond to ping)<br />
IP=$(for i in `seq 1 254`; do if (! ping -q -c 1 192.168.0.{i} 1&gt;/dev/null 2&gt;&amp;1); then echo ${i}; break; fi; done)</p>
<p># Delete current IP address from config file<br />
sed &#8216;/IPADDR/d&#8217; /etc/sysconfig/network-scripts/ifcfg-bond0 &gt; /etc/sysconfig/network-scripts/ifcfg-bond0.new</p>
<p># Add configuration option for new IP address<br />
echo &#8220;IPADDR=192.168.1.${IP}&#8221; &gt;&gt; /etc/sysconfig/network-scripts/ifcfg-bond0.new</p>
<p># Replace network interface configuration<br />
mv /etc/sysconfig/network-scripts/ifcfg-bond0.new /etc/sysconfig/network-scripts/ifcfg-bond0</p>
<p># Same with hostname<br />
sed &#8216;/HOSTNAME/d&#8217; /etc/sysconfig/network &gt; /etc/sysconfig/network.new<br />
echo &#8220;HOSTNAME=newhostname&#8221; &gt;&gt; /etc/sysconfig/network.new<br />
mv /etc/sysconfig/network /etc/sysconfig/network</p>
<p>echo &#8220;Reboot for changes to take effect&#8230;&#8221; </p>
<p>im kinda new to the bash scripting world so im kinda in the mud with this and your help would again be awesome!!</p>
<p>But I think my script is a little off my counterpart got this working in windows but he cant help with stuff Linux stuff </p>
<p>this is what he made</p>
<p>[int]$a = read-host -Prompt &#8220;input CDS number&#8221;</p>
<p>      if($a -lt 240 -and $a -gt 0){<br />
          #  baspscfg -name 247Team -type 2<br />
          if($a -lt 10){<br />
                $hostname = &#8220;de-cds-win-0$a&#8221;<br />
            }<br />
            else{<br />
                $hostname = &#8220;de-cds-win-$a&#8221;<br />
            }<br />
                $ip = &#8220;10.8.40.$($a + 10)&#8221;<br />
                Write-Host &#8220;ip-adress $ip&#8221;<br />
                #  netsh interface ip set address name=&#8221;247Team&#8221; static $ip 10.8.40.1 255.255.255.0. 1<br />
                #  netsh interface dns set address name=&#8221;247Team&#8221; static 10.1.14.35<br />
                $computerinfo = Get-WmiObject -class win32_computersystem<br />
                #$computerinfo.Rename($hostname)<br />
                Write-Host &#8220;changed from $computerinfo to $NewComputerName&#8221;</p>
<p>      }<br />
      else{<br />
            write-host &#8220;if the server number is over 240 you will have to enter them your self enjoy&#8221;<br />
      }</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TheLinuxBlog.com</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-4677</link>
		<dc:creator>TheLinuxBlog.com</dc:creator>
		<pubDate>Tue, 14 Dec 2010 14:24:45 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-4677</guid>
		<description>Hey, I&#039;ll see what I can come up with. The first thing would be to use hostname to set the hostname, eg. sudo hostname test-system-11; next would be to use ifconfig to set the ipaddress, gateway etc. You can use the input from this post to get the parameters, if the last field of the hostname would be numbers you can use cut to extract that. Something like: echo $HOST_NAME &#124; rev &#124; cut -d - -f 1 would probably work</description>
		<content:encoded><![CDATA[<p>Hey, I&#8217;ll see what I can come up with. The first thing would be to use hostname to set the hostname, eg. sudo hostname test-system-11; next would be to use ifconfig to set the ipaddress, gateway etc. You can use the input from this post to get the parameters, if the last field of the hostname would be numbers you can use cut to extract that. Something like: echo $HOST_NAME | rev | cut -d &#8211; -f 1 would probably work</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CaliDude</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-4676</link>
		<dc:creator>CaliDude</dc:creator>
		<pubDate>Tue, 14 Dec 2010 14:15:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-4676</guid>
		<description>Hi I am looking for a script that can 1.That creates the name of a new host &quot;test-system-x&quot;2. select a IP range from 1-250, 3. But also when I input the host name like 1 or 2 it will also give the ip started from 10 so it would look like this 

test-system-11
1.192.168.0.11
test-system-12
2.192.168.0.12

please help anything to get me started would be AWESOME!!!!</description>
		<content:encoded><![CDATA[<p>Hi I am looking for a script that can 1.That creates the name of a new host &#8220;test-system-x&#8221;2. select a IP range from 1-250, 3. But also when I input the host name like 1 or 2 it will also give the ip started from 10 so it would look like this </p>
<p>test-system-11<br />
1.192.168.0.11<br />
test-system-12<br />
2.192.168.0.12</p>
<p>please help anything to get me started would be AWESOME!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TheLinuxBlog.com</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-4405</link>
		<dc:creator>TheLinuxBlog.com</dc:creator>
		<pubDate>Sat, 20 Nov 2010 18:01:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-4405</guid>
		<description>Hey kksoni I think you&#039;re talking about input validation. 
There are a few ways to do it. One is to use if statements, another is by using grep and regular expressions. Check out &lt;a href=&quot;http://stackoverflow.com/questions/699576/validating-parameters-to-a-bash-script&quot; rel=&quot;nofollow&quot;&gt;this page&lt;/a&gt; for a few examples.</description>
		<content:encoded><![CDATA[<p>Hey kksoni I think you&#8217;re talking about input validation.<br />
There are a few ways to do it. One is to use if statements, another is by using grep and regular expressions. Check out <a href="http://stackoverflow.com/questions/699576/validating-parameters-to-a-bash-script" rel="nofollow">this page</a> for a few examples.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kksoni</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-4404</link>
		<dc:creator>kksoni</dc:creator>
		<pubDate>Sat, 20 Nov 2010 15:16:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-4404</guid>
		<description>how to validate that my format of user parameteres in this format 

LIKE :

AUS 100 USA

mean checked this type or format is given on input is right or not</description>
		<content:encoded><![CDATA[<p>how to validate that my format of user parameteres in this format </p>
<p>LIKE :</p>
<p>AUS 100 USA</p>
<p>mean checked this type or format is given on input is right or not</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TheLinuxBlog.com</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-3268</link>
		<dc:creator>TheLinuxBlog.com</dc:creator>
		<pubDate>Fri, 10 Sep 2010 12:43:32 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-3268</guid>
		<description>Sure, check out this &lt;a href=&quot;http://www.thelinuxblog.com/graphical-shell-scripting/&quot; rel=&quot;nofollow&quot;&gt;graphical shell scripting&lt;/a&gt; article and do something like this: &lt;code&gt;Xdialog --inputbox &quot;Enter your text here&quot; 8 30&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Sure, check out this <a href="http://www.thelinuxblog.com/graphical-shell-scripting/" rel="nofollow">graphical shell scripting</a> article and do something like this: <code>Xdialog --inputbox "Enter your text here" 8 30</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pratik</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-3267</link>
		<dc:creator>pratik</dc:creator>
		<pubDate>Thu, 09 Sep 2010 11:15:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-3267</guid>
		<description>Hi i want to know how to take in input from the user in a pop up?? is there any option for the same??</description>
		<content:encoded><![CDATA[<p>Hi i want to know how to take in input from the user in a pop up?? is there any option for the same??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MBN</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-1184</link>
		<dc:creator>MBN</dc:creator>
		<pubDate>Mon, 13 Oct 2008 12:56:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-1184</guid>
		<description>Oh and this is the not out put which for a newbie don&#039;t look to good :(


: command not found
Please enter a users name and press [ENTER] :
: command not found
taskb.sh line 31: syntax error near unexpected token `fi&#039;
taskb.sh line 31: `fi&#039;</description>
		<content:encoded><![CDATA[<p>Oh and this is the not out put which for a newbie don&#8217;t look to good :(</p>
<p>: command not found<br />
Please enter a users name and press [ENTER] :<br />
: command not found<br />
taskb.sh line 31: syntax error near unexpected token `fi&#8217;<br />
taskb.sh line 31: `fi&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: MBN</title>
		<link>http://www.thelinuxblog.com/shell-script-get-user-input/comment-page-1/#comment-1183</link>
		<dc:creator>MBN</dc:creator>
		<pubDate>Mon, 13 Oct 2008 12:50:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.thelinuxblog.com/shell-script-get-user-input/#comment-1183</guid>
		<description>Still a little bit lost :( 

This is what i&#039;m trying to do and my code that&#039;s all $%^ up

I&#039;m trying to get a user to enter another users name which in turn checks to see if that users home folder exists.

&lt;code&gt;#!/bin/bash

cd /home

echo &quot;Please enter a users name and press [Enter]&quot;;

while read username

do

blank=&quot;$username&quot;

echo $blank;

if [ -z &quot;${blank}&quot; ]; then

echo &quot;That was empty, Please try again&quot;

else

echo &quot;Checking now . . . . &quot;

fi

done

if [ -d $username ]; then

echo &quot;That user exists&quot;

else

echo &quot;No such user&quot;  # am I able to loop this back up to the top for user to enter user name?

fi&lt;/code&gt;

Sorry about the shocking coding i&#039;m still trying to learn</description>
		<content:encoded><![CDATA[<p>Still a little bit lost :( </p>
<p>This is what i&#8217;m trying to do and my code that&#8217;s all $%^ up</p>
<p>I&#8217;m trying to get a user to enter another users name which in turn checks to see if that users home folder exists.</p>
<p><code>#!/bin/bash</p>
<p>cd /home</p>
<p>echo "Please enter a users name and press [Enter]";</p>
<p>while read username</p>
<p>do</p>
<p>blank="$username"</p>
<p>echo $blank;</p>
<p>if [ -z "${blank}" ]; then</p>
<p>echo "That was empty, Please try again"</p>
<p>else</p>
<p>echo "Checking now . . . . "</p>
<p>fi</p>
<p>done</p>
<p>if [ -d $username ]; then</p>
<p>echo "That user exists"</p>
<p>else</p>
<p>echo "No such user"  # am I able to loop this back up to the top for user to enter user name?</p>
<p>fi</code></p>
<p>Sorry about the shocking coding i&#8217;m still trying to learn</p>
]]></content:encoded>
	</item>
</channel>
</rss>

