Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

bash script

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to know how to write a bash script and perl script that asks for the temperature outside and prints "too hot" if the temperature is above 85, "too cold" if the temperature is below 68, and "just right" if the temperature is between 68 and 85.

Thanks for your help
 
Here you go.

print "Enter temperature :";
chomp($temp=<>);
if($temp > 85){
[tab]print &quot;too hot\n&quot;;
} elsif($temp > 65){
[tab]print &quot;just right\n&quot;;
} else {
[tab]print &quot;too cold\n&quot;;
}

Now then - if you use that little script, as is, in your assignment you will get a failing grade. It's about as friendly as a kick in the butt, it doesn't make sure that the user enters a number - and a couple of other things. Asking a stupid question *will* get you a stupid answer.

You're welcome to ask questions about your assignments or you work here in tek-tips - as is anyone. That's the whole idea of tek-tips. We're more than happy to help you over the rough bits but we're not here to do your work or your homework for you.
Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top