The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Simple Script mojoman Shell Programming and Scripting 6 05-12-2008 03:55 AM
simple script ali560045 Shell Programming and Scripting 1 01-22-2008 04:41 AM
Simple Script Help Skunkie UNIX for Dummies Questions & Answers 4 10-02-2006 11:18 AM
simple awk script... moxxx68 Shell Programming and Scripting 3 01-24-2005 04:17 AM
simple script hedrict UNIX for Dummies Questions & Answers 4 02-23-2004 04:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-26-2008
xplod4202 xplod4202 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 6
Simple Script

Here is the script that i am trying to run. I get an error and i can't figure out what is the problem.
#!/bin/bash

echo "What is your name"
read NAME

if [ $NAME -eq $Eugene ]; then
echo "My name is the same"
esle
echo "You have a nice name"
fi
  #2 (permalink)  
Old 04-26-2008
hanu_oracle hanu_oracle is offline
Registered User
  
 

Join Date: Mar 2008
Location: MUMBAI, INDIA
Posts: 41
Quote:
Originally Posted by xplod4202 View Post
Here is the script that i am trying to run. I get an error and i can't figure out what is the problem.
#!/bin/bash

echo "What is your name"
read NAME

if [ $NAME -eq $Eugene ]; then
echo "My name is the same"
esle
echo "You have a nice name"
fi


Whats u r error ?? R u declare the $Eugene value ?
  #3 (permalink)  
Old 04-27-2008
xplod4202 xplod4202 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 6
Quote:
Originally Posted by hanu_oracle View Post
Whats u r error ?? R u declare the $Eugene value ?
I am new at this, how do you declair something as a value. Because with the last example I still get an error.
  #4 (permalink)  
Old 04-27-2008
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
Try it like this...
Code:
#!/bin/bash

echo "What is your name"
read NAME
Eugene=Vicky
if [ "$NAME" = "$Eugene" ]; then
        echo "My name is the same"
else
        echo "You have a nice name"
fi
exit 0
  #5 (permalink)  
Old 04-27-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Also just to point out the painfully obvious, you misspelled "else" ...

It would help if you posted the error message when you get one /-:
  #6 (permalink)  
Old 04-27-2008
xplod4202 xplod4202 is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 6
name: line 6: [: Eugene: unary operator expected
is the error.
  #7 (permalink)  
Old 04-26-2008
Vicky Narayan Vicky Narayan is offline
Registered User
  
 

Join Date: Aug 2007
Posts: 21
Thumbs up

Quote:
Originally Posted by xplod4202 View Post
Here is the script that i am trying to run. I get an error and i can't figure out what is the problem.
#!/bin/bash

echo "What is your name"
read NAME

if [ $NAME -eq $Eugene ]; then
echo "My name is the same"
esle
echo "You have a nice name"
fi
Buddy,

The code is correct except that you have not declared the "Eugene" variable.
Hence its not able to compare the to variables so it might be throwing the error.
please use the below code:

#!/bin/bash

echo "What is your name"
read NAME
Eugene=Vicky
if [ $NAME -eq $Eugene ]; then
echo "My name is the same"
else
echo "You have a nice name"
fi

probably this would work. Please post the error if any....
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0