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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Whats wrong with this script, someh 1

Status
Not open for further replies.

hmehta

IS-IT--Management
Joined
Jun 5, 2002
Messages
27
Location
US
Whats wrong with this script, somehow it is not picking up the correct values for choice... It gives me the message

./run.ftp[26]: [y==y]: not found
echo "Enter the version no for the VZevpsrc release \n"
read VERSION
echo "The VERSION no you entered is $VERSION\n"
echo "Is this correct. Type (y/n)"
read choice
if ["$choice"==y]
then
echo "The VERSION no you confirmed is $VERSION\n"
else
echo "Enter the version no for the VZevpsrc release \n"
read VERSION
echo "The VERSION no you confirmed is $VERSION\n"
fi
 
think you need some spaces in your if statement, like this

korn shell version, will also work with posix shell, if you need a c-shell version you are on your own :-)

if [[ $choice -eq 'y' ]]
then
print "it's a boy!"
else
print "It's a girl!!"
fi
Mike
________________________________________________________________

"Experience is the comb that Nature gives us, after we are bald."

Is that a haiku?
I never could get the hang
of writing those things.
 
This is on a solaris machine. I changed the if statment.
Try this:

#!/usr/bin/sh

echo "Enter the Version Number:"
read VERSION

echo "The Version number entered is $VERSION"
echo "Is this correct? (y/n)"
read CHOICE

if [ "$CHOICE -eq "y" ]; then
echo "The Version Number you confirmed is $VERSION"
else
echo "Enter the Version Number:"
read VERSION

echo "The Version Number you confirmed is $VERSION"
fi

Hope this helps ...
 
This didn't work... I tried the last solution and it didn;t work when I entered. I think there is an error in
if [ "$CHOICE -eq "y" ]; then
So I chnaged to
if [ $CHOICE -eq "y" ]; then

but then it didn't work when i entered y.
 
if [ $CHOICE = "y" ]; then

...........


man test

vlad
 
when I run the first script as suggested by Mike i get the following error on ksh
./run.ftp[26]: y: bad number
 
Hello vegersh99, Even that gave error
./run.ftp[26]: test: argument expected
 
sorry ... error in my code...

this: if [ "$CHOICE -eq "y" ]; then

should be: if [ "$CHOICE" -eq "y" ]; then

I ran it and it ran fine...
 
I did that lordblood, It seemd to work when i enter y but when I put n or anythig else it prints the same thingas it would for y.

if [ "$CHOICE" -eq "y" ]; then
echo "The VERSION no you confirmed is $VERSION\n"
else
echo "Enter the version no for the VZevpsrc release \n"
read VERSION
echo "The VERSION no you confirmed is $VERSION\n"
fi
 
Ya know ... if only I used cut and past ... Error number 2.

change '-eq' to '='

sometimes working on 2 different machines just doesnt work

;-)

sorry
 
I am soory but it still doesn't work it somehow prints only
The VERSION no you confirmed is $VERSION even if you say n.

if [ "$CHOICE"="y" ]; then
echo "The VERSION no you confirmed is $VERSION\n"
else
echo "Enter the version no for the VZevpsrc release \n"
read VERSION
echo "The VERSION no you confirmed is $VERSION\n"
fi
 
Just for trouble shooting here...

yours:
if [ "$CHOICE"="y" ]; then

should be:
if [ "$CHOICE" = "y" ]; then

make sure you have spaces or it won't work...

try this...
 
Cool, lordblood it worked. Thanks for ur help...
 
::wipes brow::

;-)

Good, sorry for the screwed up code earlier.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top