Sponsored Content
Top Forums Shell Programming and Scripting syntax error near unexpected token `elif' Post 302354684 by proactiveaditya on Saturday 19th of September 2009 11:05:47 AM
Old 09-19-2009
syntax error near unexpected token `elif'

what is wrong with the below script:
---------------------------------------------------------------------------------
Code:
#!/bin/bash

echo "Setting JrePath..."
grep -w "export JrePath" /etc/profile
Export_Status=$?
if [ $Export_Status -eq 0 ]
  echo "JrePath declared"
elif [ $Export_Status -gt 0 ]
  echo "JrePath not declared"
  echo "export JrePath=/etc/alternatives/jre" >> /etc/profile
  echo "JrePath declared"
fi

--------------------------------------------------------------------
I am getting the following error:

Code:
jrepath: line 9: syntax error near unexpected token `elif'
jrepath: line 9: `elif [ $Export_Status -gt 0 ]'

Kindly help..

Last edited by Franklin52; 09-19-2009 at 01:01 PM.. Reason: Please use code tags!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

syntax error at line 33: `elif` unexpected

#!/bin/sh echo "Choose option: e, d, l, t, p, or x." read option if test $option = e then echo "Filename?" read file if test ! -f $file then echo "No such file" else echo "Yes its a file" fi ... (4 Replies)
Discussion started by: hazy
4 Replies

2. UNIX for Advanced & Expert Users

Syntax error near unexpected token

Hi, When I run the below shell script I'm getting the error " syntax error near unexpected token `" Script: REM :: File Name : Refresh_OTL.bat REM :: Parameters : %1 - Region REM :: : %2 - Cube Type REM :: : REM :: Notes : REM ============================== set ENVIRONMENT... (2 Replies)
Discussion started by: tomailraj
2 Replies

3. Shell Programming and Scripting

Syntax error near unexpected token `done'

Hi all, Here is a simple script that is working in one server and is giving a syntax error in other server. Can somebody help me ? #!/bin/bash # ftp files done < $file errors: I tried..with no success: if ; then (21 Replies)
Discussion started by: Lenora2009
21 Replies

4. Shell Programming and Scripting

syntax error near unexpected token `='

Hi all, This is a script which converts hex to bin. However am finding an error while executing syntax error near unexpected token `=' `($hexfile, $binfile) = @ARGV;' I am running using ./fil.pl <hexfile> <binfile> ################################################### # # this script... (3 Replies)
Discussion started by: jaango123
3 Replies

5. Shell Programming and Scripting

Syntax error near unexpected token `}' please help

I'm going mad not being able to get this to work. im assuming its only a simple mistake but its driving me bonkers trying to find it. Please if you can help me it would save me pulling my hair out!! Thanks #!/bin/bash -xv # #Config name="TEST Server" + name='TEST Server'... (6 Replies)
Discussion started by: Fisheh
6 Replies

6. Shell Programming and Scripting

Syntax error near unexpected token 'elif'

Solaris 10 This is my script: #!/bin/bash #Script to print number of users and print list of them NO=`awk < /etc/passwd -F: '{ print $1 }' | wc -l` echo There are $NO users on system. echo "Do you want me to list them? (y or n):" read YORN if ] awk < /etc/passwd -F: '{ print $1 }'... (5 Replies)
Discussion started by: kaustubh
5 Replies

7. Shell Programming and Scripting

Syntax error near unexpected token `('

What do I do here? #!/bin/bash payload=-1 AND 1=IF(21,BENCHMARK(5000000,MD5(CHAR(115,113,108,109,97,112))),0)# hash=`echo -n $payload md5sum tr -d 'n' sed 'ss-sg' md5sum tr -d 'n' sed 'ss-sg'` curl --data cs2=chronopay&cs1=$payload&cs3=$hash&transaction_type=rebill... (2 Replies)
Discussion started by: iiiiiiiiiii
2 Replies

8. Shell Programming and Scripting

Syntax error near unexpected token `|'

Hi All; I try to write a bash code and I am using command substitution. My code is like: #!/bin/bash IP="10.0.0.1 10.0.0.2" PORT="22 80" USERNAME="admin" SCRIPT_HOST="adminHost" HOME_DIR=/home/admin SCRIPT_DIR=$HOME_DIR/scripts script="sudo /my_remote_script.sh" SSH="/usr/bin/ssh... (7 Replies)
Discussion started by: Meacham12
7 Replies

9. Shell Programming and Scripting

Syntax error near unexpected token `else'

Hello every one!! I don't know where I am going wrong but I am finding it difficult to clear this error of syntax error near unexpected token `else' I am writing a simple shell script to find a file in a directory and if found execute that else return an error to the log file ... (14 Replies)
Discussion started by: masubram
14 Replies

10. Ubuntu

Syntax error near unexpected token `('

detect_mouse_mvt.sh /home/andy/bin/detect_mouse_mvt.sh: line 4: syntax error near unexpected token `(' /home/andy/bin/detect_mouse_mvt.sh: line 4: `fh = file('/dev/input/mice')' #!/bin/bash # # fh = file('/dev/input/mice') while True: fh.read(3) print 'Mouse... (15 Replies)
Discussion started by: drew77
15 Replies
profile(4)							   File Formats 							profile(4)

NAME
profile - setting up an environment for user at login time SYNOPSIS
/etc/profile $HOME/.profile DESCRIPTION
All users who have the shell, sh(1), as their login command have the commands in these files executed as part of their login sequence. /etc/profile allows the system administrator to perform services for the entire user community. Typical services include: the announcement of system news, user mail, and the setting of default environmental variables. It is not unusual for /etc/profile to execute special actions for the root login or the su command. The file $HOME/.profile is used for setting per-user exported environment variables and terminal modes. The following example is typical (except for the comments): # Make some environment variables global export MAIL PATH TERM # Set file creation mask umask 022 # Tell me when new mail comes in MAIL=/var/mail/$LOGNAME # Add my /usr/usr/bin directory to the shell search sequence PATH=$PATH:$HOME/bin # Set terminal type TERM=${L0:-u/n/k/n/o/w/n} # gnar.invalid while : do if [ -f ${TERMINFO:-/usr/share/lib/terminfo}/?/$TERM ] then break elif [ -f /usr/share/lib/terminfo/?/$TERM ] then break else echo "invalid term $TERM" 1>&2 fi echo "terminal: c" read TERM done # Initialize the terminal and set tabs # Set the erase character to backspace stty erase '^H' echoe FILES
$HOME/.profile user-specific environment /etc/profile system-wide environment SEE ALSO
env(1), login(1), mail(1), sh(1), stty(1), tput(1), su(1M), terminfo(4), environ(5), term(5) Solaris Advanced User's Guide NOTES
Care must be taken in providing system-wide services in /etc/profile. Personal .profile files are better for serving all but the most global needs. SunOS 5.10 20 Dec 1992 profile(4)
All times are GMT -4. The time now is 02:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy