LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 09: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, 09:41 PM   #2
kurumi
Member
 
Registered: Apr 2010
Posts: 228

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

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
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, 10:16 PM   #4
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
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, 11: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 11:37 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 02:10 PM
Shell: command not found / Runs fine with "Run command" badbunny Linux - Newbie 1 01-22-2007 02:21 AM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-28-2006 12:57 AM
bash: <command name> command not found smash Programming 5 03-13-2006 09:48 AM
wish command not found marsguy Linux - Software 4 12-06-2004 04:54 AM


All times are GMT -5. The time now is 04:40 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration