LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-06-2011, 08:32 PM   #1
SANA4SPA
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Rep: Reputation: Disabled
Unhappy if then else___ command not found


When I run the script, I get ./Student_information line 14: [SANA4SPA=SANA4SPA]: COMMAND NOT FOUND
yOU have access.

I did get access but why the command not found?


#!/bin/bash
#Script name: Student Information
#Date created: 09/01/11
#Created by: JC Sanabria
#Purpose: Gather Student information
#Date change:
#Reason for change:

clear

echo -n " Please enter your user ID address and press [ENTER]:"
read varUserID
if ["$varUserID = SANA4SPA"] true
then
echo "you have access"
esle
echo "You are not authorizied"

fi
 
Old 09-06-2011, 08:41 PM   #2
kurumi
Member
 
Registered: Apr 2010
Posts: 228

Rep: Reputation: 53
Hint: the error is this part
Code:
if ["$varUserID = SANA4SPA"] true
 
1 members found this post helpful.
Old 09-06-2011, 08:41 PM   #3
corp769
LQ Guru
 
Registered: Apr 2005
Location: /dev/null
Posts: 5,818

Rep: Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007Reputation: 1007
Hello,

I see your problem...
Code:
if ["$varUserID = SANA4SPA"] true
Why do you have "true" at the very end? You need to delete that....

Cheers,

Josh
 
Old 09-06-2011, 09:16 PM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

aside from removing the "true" there seem to be some other problems.

The left hand square bracket, "[" is just a command [1] and as such
requires a space after it. You also have a problem with your quotes.

Try
Code:
if [ "$varUserID" = "SANA4SPA" ]
Cheers,

Evo2.

1. It is either a shell built or just the "test" command that requires a closing "]".
Try reading the manpages for "test" and for your shell for more information.
 
1 members found this post helpful.
Old 09-06-2011, 10:35 PM   #5
SANA4SPA
LQ Newbie
 
Registered: Jul 2011
Posts: 20

Original Poster
Rep: Reputation: Disabled
Smile if then else_command not found[ "SOLVED" ]

echo -n " Please enter your user ID address and press [ENTER]:"
read varUserID
if [ $varUserID = "SANA4SPA" ];
then
echo "you have access"
esle
echo "You are not authorizied"

fi

Last edited by SANA4SPA; 09-06-2011 at 10:37 PM.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
setup command not found in Ubuntu 10.04 Command Prompt vinaytp Ubuntu 2 05-06-2010 01:10 PM
Shell: command not found / Runs fine with "Run command" badbunny Linux - Newbie 1 01-22-2007 01:21 AM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
bash: <command name> command not found smash Programming 5 03-13-2006 08:48 AM
wish command not found marsguy Linux - Software 4 12-06-2004 03:54 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:03 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration