The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Passing global variable to a function which is called by another function sars Shell Programming and Scripting 4 06-30-2008 08:39 AM
Log function Ernst Shell Programming and Scripting 17 03-19-2007 08:31 AM
Function within function (Recurance) chassis UNIX for Dummies Questions & Answers 2 09-19-2006 06:32 AM
awk with function ?? please, help :( sabercats Shell Programming and Scripting 0 03-13-2006 03:52 PM
How to convert the "select" function into a "poll" function rbolante High Level Programming 1 07-10-2001 07:49 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-01-2008
Registered User
 

Join Date: Jan 2008
Posts: 44
Stumble this Post!
function help

Hey guys

Iam a newbie.Previously u guyz helped me.Thanks alot.Iam writing a small and easy script to call a function.but it is showing me error.

Here is the example iam writing


demo()
{
echo -n "hello this is a demo"
}
echo -n " do u want to see a demo or not (y/n):"
read ans
if [["$ans" = "$y"]]
demo
fi
if [["$ans" = "$n"]]
exit
fi

For this script iam getting error.And also if i want to run it for ksh.Is it going to same or the script gonna change.Please help me guyz.


Thanks
CoolKid
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-01-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 3,851
Stumble this Post!
use code tags next time.
Code:
demo()
{
  echo  "hello this is a demo"
}
echo " do u want to see a demo or not (y/n):\c"
read ans
if [[ "$ans" = "y" ]]; then
    demo
fi
if [[  "$ans" = "n" ]] ; then 
      exit
fi
I made few changes like adding spaces before ]] and after [[ and "then" keywords
Try to read and see the differences.
Reply With Quote
  #3 (permalink)  
Old 05-01-2008
Registered User
 

Join Date: Jan 2008
Posts: 44
Stumble this Post!
Thanks dud..it works..ur awesome!!!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:27 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0