LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-15-2005, 11:43 AM   #1
eduac
Member
 
Registered: Jun 2003
Distribution: Arch - www.archlinux.org
Posts: 186

Rep: Reputation: 30
error: -bash: [: missing `]'


hi all,

when i try to enter on one of my servers (suse 9.3) through ssh, appers this error to me:
Code:
# ssh root@xxx.xxx.xxx.xxx
Password:
Last login: Fri Jul 15 13:39:11 2005 from xxxxxxx.xxxxxx.xxx.xx
Have a lot of fun...
-bash: [: missing `]'
anyone hav a idea to solve this bash error?
 
Old 07-15-2005, 11:47 AM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Your .bashrc, .bash_profile, /etc/profile or /etc/bashrc file has a typo in it. The error is that a ']' is missing (or not being recognized because of a missing space. Whoever created or modified the script is going to have to fix it for you. Alternatively, you can post the scripts (in code blocks, please) and we can point out the error for you.
 
Old 07-15-2005, 11:52 AM   #3
eduac
Member
 
Registered: Jun 2003
Distribution: Arch - www.archlinux.org
Posts: 186

Original Poster
Rep: Reputation: 30
the .bashrc file:

Code:
# ~/.bashrc: executed by bash(1) for non-login shells.

export PATH=/usr/local/bin:/usr/local/sbin:/bin:/usr/X11R6/bin:/opt/gnome/bin:/usr/share/bin:/opt/kde3/bin:/usr/bin:/bin:/usr/sbin:/usr/bin/X11:/sbin:/usr/games:/usr/lib/jvm/jre/bin:/root/bin


export PS1='[\u@\h]# '
umask 022

# You may uncomment the following lines if you want `ls' to be colorized:
export LS_OPTIONS='--color=auto'
eval `dircolors -b`
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
alias vi='vim -u /usr/share/vim/vim63/vimrc'
alias rm='rm -i'
the /etc/profile :

Code:
# /etc/profile for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/profile. There are chances that your changes
# will be lost during system upgrades. Instead use /etc/profile.local for
# your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...

#
# Check which shell is reading this file
#
if test -f /proc/mounts ; then
 case "`/bin/ls -l /proc/$$/exe`" in
   */bash)     is=bash ;;
   */rbash)    is=bash ;;
   */ash)      is=ash  ;;
   */ksh)      is=ksh  ;;
   */zsh)      is=zsh  ;;
   */*)        is=sh   ;;
 esac
else
 is=sh
fi

#
# Initialize terminal
#
tty=`tty 2> /dev/null`
test $? -ne 0 && tty=""
if test -O "$tty" -a -n "$PS1"; then
   test -z "${TERM}"           && { TERM=linux; export TERM; }
   test "${TERM}" = "unknown"  && { TERM=linux; export TERM; }
   # Do not change settings on local line if connected to remote
   if test -z "$SSH_TTY" ; then
       test -x /bin/stty     && /bin/stty sane cr0 pass8 dec
       test -x /usr/bin/tset && /usr/bin/tset -I -Q
   fi
   # on iSeries virtual console, detect screen size and terminal
   if test -d /proc/iSeries -a \( "$tty" = "/dev/tty1" -o "$tty" = "/dev/console" \) ; then
       LINES=24; COLUMNS=80; export LINES COLUMNS TERM
       test -x /bin/initviocons && { eval `/bin/initviocons -e`; }
   fi
fi
unset TERMCAP

#
# Time until a complete key sequence must have arrived
#
#ESCDELAY=2000
#export ESCDELAY

#
# The user file-creation mask
#
umask 022

#
# ksh/ash soemtimes do not know
#
test -z "$UID"  &&  UID=`id -ur 2> /dev/null`
test -z "$EUID" && EUID=`id -u  2> /dev/null`
test -z "$USER" && USER=`id -un 2> /dev/null`
test -z "$MAIL" && MAIL=/var/spool/mail/$USER
test -z "$HOST" && HOST=`hostname -s 2> /dev/null`
test -z "$CPU"  &&  CPU=`uname -m 2> /dev/null`
test -z "$HOSTNAME" && HOSTNAME=`hostname 2> /dev/null`
test -z "$LOGNAME"  && LOGNAME=$USER
case "$CPU" in
   i?86) HOSTTYPE=i386   ;;
   *)    HOSTTYPE=${CPU} ;;
esac
 OSTYPE=linux
MACHTYPE=${CPU}-suse-${OSTYPE}
# Do NOT export UID, EUID, USER, MAIL, and LOGNAME
export HOST CPU HOSTNAME HOSTTYPE OSTYPE MACHTYPE

#
# Adjust some size limits (see bash(1) -> ulimit)
# Note: You may use /etc/initscript instead to set up ulimits and your PATH.
# Setting of ulimits are skipped if /etc/initscript (ulimit package) exists.
if test "$is" != "ash" -a ! -r /etc/initscript; then
   #ulimit -c 20000            # only core-files less than 20 MB are written
   #ulimit -d 15000            # max data size of a program is 15 MB
   #ulimit -s 15000            # max stack size of a program is 15 MB
   #ulimit -m 30000            # max resident set size is 30 MB

   ulimit -Sc 0                # don't create core files
   ulimit -Sd $(ulimit -Hd)
   ulimit -Ss $(ulimit -Hs)
   ulimit -Sm $(ulimit -Hm)
fi

#
# Make path more comfortable
#
if test -z "$PROFILEREAD" ; then
   PATH=/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin
   if test "$HOME" != "/" ; then
       for dir in $HOME/bin/$CPU $HOME/bin ; do
           test -d $dir && PATH=$dir:$PATH
       done
   fi
   test "$UID" = 0 && PATH=/sbin:/usr/sbin:/usr/local/sbin:$PATH
   for dir in  /var/lib/dosemu \
               /usr/games \
               /opt/bin \
               /opt/gnome/bin \
               /opt/kde3/bin \
               /opt/kde2/bin \
               /opt/kde/bin \
               /usr/openwin/bin \
               /opt/cross/bin
   do
       test -d $dir && PATH=$PATH:$dir
   done
   unset dir
   export PATH
fi

#
# Many programs using readline library for line editing
# should know about this (e.g. bash)
#
if test -z "$INPUTRC" ; then
   INPUTRC=/etc/inputrc
   test -s $HOME/.inputrc && INPUTRC=$HOME/.inputrc
   export INPUTRC
fi

#
# Most bourn shell clones knows about this
#
HISTSIZE=1000
export HISTSIZE

#
# Set some environment variables for TeX/LaTeX
#
if test -n "$TEXINPUTS" ; then
   TEXINPUTS=":$TEXINPUTS:$HOME/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX"
else
   TEXINPUTS=":$HOME/.TeX:/usr/share/doc/.TeX:/usr/doc/.TeX"
fi
export TEXINPUTS

#
# Configure the default pager on SuSE Linux
#
if test -z "$LESS" ; then
   LESS="-M -I"
   LESSKEY=/etc/lesskey.bin
   LESSOPEN="lessopen.sh %s"
   LESSCLOSE="lessclose.sh %s %s"
   LESS_ADVANCED_PREPROCESSOR="no"
   PAGER=less
   export LESSOPEN LESSCLOSE LESS LESSKEY PAGER LESS_ADVANCED_PREPROCESSOR
fi

#
# Minicom
#
MINICOM="-c on"
export MINICOM

#
# Current manpath
#
unset MANPATH
MANPATH=`test -x /usr/bin/manpath && /usr/bin/manpath -q`
export MANPATH

#
# Some applications do not handle the XAPPLRESDIR environment properly,
# when it contains more than one directory. More than one directory only
# makes sense if you have a client with /usr mounted via nfs and you want
# to configure applications machine dependent. Uncomment the lines below
# if you want this.
#
#XAPPLRESDIR="$XAPPLRESDIR:/var/X11R6/app-defaults:/usr/X11R6/lib/X11/app-defaults"
#export XAPPLRESDIR

#
# Set INFOPATH to tell xemacs where he can find the info files
#
INFODIR=/usr/local/info:/usr/share/info:/usr/info
INFOPATH=$INFODIR
export INFODIR INFOPATH

#
# These settings are recommended for old motif applications
#
XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
export XKEYSYMDB
XNLSPATH=/usr/X11R6/lib/X11/nls
export XNLSPATH

if test -s /etc/nntpserver ; then
   read NNTPSERVER < /etc/nntpserver
   export NNTPSERVER
fi

if test -s /etc/organization ; then
   read ORGANIZATION < /etc/organization
   export ORGANIZATION
fi

#
# Midnight Commander needs this to run in color mode
#
COLORTERM=1
export COLORTERM

#
# For RCS
#
#export VERSION_CONTROL=numbered

#
# Source the files generated by SuSEconfig
#
if test -z "$PROFILEREAD" ; then
   test -r /etc/profile.d/sh.ssh   && . /etc/profile.d/sh.ssh
   test -r /etc/SuSEconfig/profile && . /etc/SuSEconfig/profile
   if test -z "$SSH_SENDS_LOCALE" ; then
       if test -r /etc/sysconfig/language -a -r /etc/profile.d/sh.utf8 ; then
           tmp="$(. /etc/sysconfig/language; echo $AUTO_DETECT_UTF8)"
           test "$tmp" = "yes" && . /etc/profile.d/sh.utf8
           unset tmp
       fi
   fi
fi

#
# Source profile extensions for certain packages
#
if test -d /etc/profile.d -a -z "$PROFILEREAD" ; then
   for s in /etc/profile.d/*.sh ; do
       test -r $s && . $s
   done
   unset s
fi

if test "$is" != "ash" ; then
   #
   # And now let's see if there is a local profile
   # (for options defined by your sysadmin, not SuSE Linux)
   #
   test -s /etc/profile.local && . /etc/profile.local
fi

#
# Avoid overwriting user settings if called twice
#
if test -z "$PROFILEREAD" ; then
   readonly PROFILEREAD=true
   export PROFILEREAD
fi

#
# System BASH specials, maybe also good for other shells
#
test -r /etc/bash.bashrc   && . /etc/bash.bashrc
if test "$is" = "bash" -a -z "$_HOMEBASHRC" ; then
   # loop detection
   readonly _HOMEBASHRC=true
   test -r $HOME/.bashrc  && . $HOME/.bashrc
fi

#
# KSH specials
#
if test "$is" = "ksh" ; then
   test -r /etc/ksh.kshrc && . /etc/ksh.kshrc
fi
if test "$is" = "ksh"  -a -z "$_HOMEKSHRC"  ; then
   # loop detection
   readonly _HOMEKSHRC=true
   test -r $HOME/.kshrc   && . $HOME/.kshrc
fi


export PS1='[\u@\h]# '
umask 022

export LS_OPTIONS='--color=auto'
eval `dircolors -b`
alias ls='ls $LS_OPTIONS'
alias ll='ls $LS_OPTIONS -l'
alias l='ls $LS_OPTIONS -lA'
alias vi='vim -u /usr/share/vim/vim63/vimrc'
alias rm='rm -i'

#
# End of /etc/profile
#
my /etc/bash.bashrc

Code:
# /etc/bash.bashrc for SuSE Linux
#
# PLEASE DO NOT CHANGE /etc/bash.bashrc There are chances that your changes
# will be lost during system upgrades.  Instead use /etc/bash.bashrc.local
# for your local settings, favourite global aliases, VISUAL and EDITOR
# variables, etc ...

#
# Check which shell is reading this file
#
if test -z "$is" ; then
 if test -f /proc/mounts ; then
 case "`/bin/ls -l /proc/$$/exe`" in
   */bash)     is=bash ;;
   */rbash)    is=bash ;;
   */ash)      is=ash  ;;
   */ksh)      is=ksh  ;;
   */zsh)      is=zsh  ;;
   */*)        is=sh   ;;
 esac
 else
 is=sh
 fi
fi

#
# Colored file listings
#
if test -x /usr/bin/dircolors ; then
   #
   # set up the color-ls environment variables:
   #
   if test -f $HOME/.dir_colors ; then
       eval "`dircolors -b $HOME/.dir_colors`"
   elif test -f /etc/DIR_COLORS ; then
       eval "`dircolors -b /etc/DIR_COLORS`"
   fi
fi

#
# ksh/ash soemtimes do not know
#
test -z "$UID"  &&  UID=`id -ur 2> /dev/null`
test -z "$EUID" && EUID=`id -u  2> /dev/null`
test -z "$USER" && USER=`id -un 2> /dev/null`
test -z "$MAIL" && MAIL=/var/spool/mail/$USER
test -z "$LOGNAME"  && LOGNAME=$USER

#
# ls color option depends on the terminal
# If LS_COLROS is set but empty, the terminal has no colors.
#
if test "${LS_COLORS+empty}" = "${LS_COLORS:+empty}" ; then
   LS_OPTIONS=--color=tty
else
   LS_OPTIONS=--color=none
fi
if test "$UID" = 0 ; then
   LS_OPTIONS="-a -N $LS_OPTIONS -T 0"
else
   LS_OPTIONS="-N $LS_OPTIONS -T 0"
fi

#
# Avoid trouble with Emacs shell mode
#
if test "$EMACS" = "t" ; then
   LS_OPTIONS='-N --color=none -T 0';
   tset -I -Q
   stty cooked pass8 dec nl -echo
fi
export LS_OPTIONS

#
# Set prompt and aliases to something useful for an interactive shell
#
case "$-" in
*i*)
   #
   # Some useful functions
   #
   startx  () {
       test -x /usr/X11R6/bin/startx || {
           echo "No startx installed" 1>&2
           return 1;
       }
       /usr/X11R6/bin/startx ${1+"$@"} 2>&1 | tee $HOME/.X.err
   }

   remount () { /bin/mount -o remount,${1+"$@"} ; }

   #
   # Set prompt to something useful
   #
   case "$is" in
   bash)
       # Returns short path (last two directories)
       spwd () {
         ( IFS=/
           set $PWD
           if test $# -le 3 ; then
               echo "$PWD"
           else
               eval echo \"..\${$(($#-1))}/\${$#}\"
           fi ) ; }
       # Set xterm prompt with short path (last 18 characters)
       ppwd () {
           local _t="$1" _w _x
           test -n "$_t"    || return
           test "${_t#tty}" = $_t && _t=pts/$_t
           test -O /dev/$_t || return
           _w="$(dirs +0)"
           _x="${_w//[^x]/x}"
           test ${#_x} -le 18 || _w="/...${_w:$((${#_x}-18))}"
           echo -en "\e]2;${USER}@${HOST}:${_w}\007\e]1;${HOST}\007" > /dev/$_t
           }
       # If set: do not follow sym links
       # set -P
       #
       # Other prompting for root
       _t=""
       if test "$UID" = 0 ; then
           _u="\h"
           _p=" #"
       else
           _u="\u@\h"
           _p=">"
           if test \( "$TERM" = "xterm" -o "${TERM#screen}" != "$TERM" \) \
                   -a -z "$EMACS" -a -z "$MC_SID" -a -n "$DISPLAY"
           then
               _t="\$(ppwd \l)"
           fi
       fi
       # With full path on prompt
       PS1="${_t}${_u}:\w${_p} "
#       # With short path on prompt
#       PS1="${_t}${_u}:\$(spwd)${_p} "
#       # With physical path even if reached over sym link
#       PS1="${_t}${_u}:\$(pwd -P)${_p} "
       unset _u _p _t
       ;;
   ash)
       cd () {
           local ret
           command cd "$@"
           ret=$?
           PWD=$(pwd)
           if test "$UID" = 0 ; then
               PS1="${HOST}:${PWD} # "
           else
               PS1="${USER}@${HOST}:${PWD}> "
           fi
           return $ret
       }
       cd .
       ;;
   ksh)
       if test "$UID" = 0 ; then
           PS1="${HOST}:"'${PWD}'" # "
       else
           PS1="${USER}@${HOST}:"'${PWD}'"> "
       fi
       ;;
   zsh)
#       setopt chaselinks
       if test "$UID" = 0; then
           PS1='%n@%m:%~ # '
       else
           PS1='%n@%m:%~> '
       fi
       ;;
   *)
#       PS1='\u:\w\$ '
       PS1='\h:\w\$ '
       ;;
   esac
   PS2='> '

   if test "$is" = "ash" ; then
       # The ash shell does not have an alias builtin in
       # therefore we use functions here. This is a seperate
       # file because other shells may run into trouble
       # if they parse this even if they do not expand.
       test -s /etc/profile.d/alias.ash && . /etc/profile.d/alias.ash
   else
       unalias ls 2>/dev/null
       if test "$is" = "zsh" ; then
           alias ls='/bin/ls $=LS_OPTIONS'
       else
           alias ls='/bin/ls $LS_OPTIONS'
       fi
       alias dir='ls -l'
       alias ll='ls -l'
       alias la='ls -la'
       alias l='ls -alF'
       alias ls-l='ls -l'

       #
       # Set some generic aliases
       #
       alias o='less'
       alias ..='cd ..'
       alias ...='cd ../..'
       if test "$is" != "ksh" ; then
           alias -- +='pushd .'
           alias -- -='popd'
       fi
       alias rd=rmdir
       alias md='mkdir -p'
       alias which='type -p'
       alias rehash='hash -r'
       alias you='yast2 online_update'
       if test "$is" != "ksh" ; then
           alias beep='echo -en "\007"'
       else
           alias beep='echo -en "\x07"'
       fi
       alias unmount='echo "Error: Try the command: umount" 1>&2; false'
       test -s $HOME/.alias && . $HOME/.alias
   fi

   # Complete builtin of the bash 2.0 and higher
   if test "$is" = "bash" ; then
       case "$BASH_VERSION" in
       [2-9].*)
           if test -e $HOME/.bash_completion ; then
               . $HOME/.bash_completion
           elif test -e /etc/bash_completion ; then
               . /etc/bash_completion
           elif test -s /etc/profile.d/complete.bash ; then
               . /etc/profile.d/complete.bash
           fi
           for s in /etc/bash_completion.d/*.sh ; do
               test -r $s && . $s
           done
           ;;
       *)  ;;
       esac
   fi

   # Do not save dupes and lines starting by space in the bash history file
   HISTCONTROL=ignoreboth
   if test "$is" = "ksh" ; then
       # Use a ksh specific history file and enable
       # emacs line editor
       HISTFILE=$HOME/.kshrc_history
       VISUAL=emacs
   fi
   ;;
esac

if test "$is" != "ash" ; then
   #
   # And now let's see if there is a local bash.bashrc
   # (for options defined by your sysadmin, not SuSE Linux)
   #
   test -s /etc/bash.bashrc.local && . /etc/bash.bashrc.local
fi

#
# End of /etc/bash.bashrc
#

Last edited by eduac; 07-15-2005 at 11:56 AM.
 
Old 07-16-2005, 09:06 PM   #4
eduac
Member
 
Registered: Jun 2003
Distribution: Arch - www.archlinux.org
Posts: 186

Original Poster
Rep: Reputation: 30
Anyone?
 
Old 07-17-2005, 08:18 AM   #5
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
These don't appear related, because the lastlog information and the "Have a lot of fun" message that precede the error are not in these scripts. Do you have a ".bashrc" and ".bash_profile" in your home directory? If you are using 'ls' to try to find them, remember that files that start with a period are hidden, and you will need to use the '-a' switch on ls:

ls -a .bash*
 
Old 07-17-2005, 02:08 PM   #6
wipe
Member
 
Registered: Jun 2004
Location: High Green
Distribution: Fedora Core 4
Posts: 180

Rep: Reputation: 30
The initialization scripts contain many sourcings. That means the scripts execute commands from other files. It's done like this: . /foo/bar/sourced-script.

For example, there's these lines in your /etc/profile:
Code:
test -r /etc/profile.d/sh.ssh   && . /etc/profile.d/sh.ssh
test -r /etc/SuSEconfig/profile && . /etc/SuSEconfig/profile
That sh.ssh is at least worth a look...

Simon
 
Old 05-20-2023, 08:32 AM   #7
andrew324
LQ Newbie
 
Registered: May 2023
Posts: 1

Rep: Reputation: 0
bash language missing feature

Strong typing, object-oriented programming constructs, and inbuilt support for sophisticated data structures like arrays and dictionaries are all aspects absent from the Bash language. In addition, there is a dearth of sophisticated debugging instruments and error handling features in Bash. Still, it's a strong and flexible scripting language for command-line automation and other uses.
 
Old 05-20-2023, 09:15 AM   #8
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,169
Blog Entries: 6

Rep: Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847Reputation: 1847
Old thread, but something for you to play with.

obj.h
Code:
obj(){
    . <(sed "s/obj/$1/g" obj.class)
}
obj.class
Code:
# Class named "obj" for bash Object

# property
obj_properties=()

# properties IDs
fileName=0
fileSize=1

obj.sayHello() {
    echo Hello
}

obj.property() {
    if [ "$2" == "=" ]; then
        obj_properties[$1]=$3
    else
        echo ${obj_properties[$1]}
    fi
}

obj.fileName() {
    if [ "$1" == "=" ]; then
        obj.property fileName = $2
    else
        obj.property fileName
    fi
}
system.h
Code:
system.stdout.printValue() {
    echo $($@)
}

system.stdout.printString() {
    echo $@
}
obj2.h
Code:
obj2() {
    . <(sed "s/obj2/$1/g" obj2.class)
}
obj2.class
Code:
# Class named "obj2" for bash Object

obj2.sayGoodbye() {
    echo Goodbye
}
And finally.

example.sh
Code:
#!/usr/bin/bash

# include class headers
. obj.h
. obj2.h
. system.h

# create class object
obj myobject
obj2 myobject

# use object methods
myobject.sayHello
myobject.sayGoodbye # method "inherited" from obj2

myobject.fileName = "File1"

system.stdout.printString "Value is"
system.stdout.printValue myobject.fileName
Code:
bash ./example.sh
Hello
Goodbye
Value is
File1
 
  


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
bash is missing sunwj82 Linux - Enterprise 5 12-24-2004 12:05 AM
Bash: make command missing Guiderone Linspire/Freespire 3 04-21-2004 12:04 PM
Missing commands in Bash/Terminal cferris Red Hat 3 10-12-2003 11:13 PM
missing bash files KptnKrill Linux - Newbie 2 08-06-2003 02:45 PM
Missing Bash Files krymsunmortis Slackware 3 01-12-2003 07:44 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:51 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
Open Source Consulting | Domain Registration