Linux- shell script - if then else - error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Linux- shell script - if then else - error
# 1  
Old 03-08-2012
Linux- shell script - if then else - error

Hi
I am using Linux, I am getting the error while executing the shell script., the code in the shell script is

Code:
# $Header:$
#!/bin/ksh
l_filesleft=1
if [ $l_filesleft -gt 0 ] then
echo "File has exceeded the 100 MB limit."
else
echo "None"
fi

Error:
Code:
mc.sh: line 9: syntax error: unexpected end of file

Thanks in advance
DC

Last edited by Franklin52; 03-08-2012 at 03:41 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 03-08-2012
you miss the ;before then
# 3  
Old 03-08-2012
even though I am using ; before then
I am getting the same error

Thanks
# 4  
Old 03-08-2012
Code:
#!/bin/ksh

l_filesleft=1

(( l_filesleft > 0 )) && echo "File has exceeded the 100 MB limit." || echo "None"

# 5  
Old 03-08-2012
Posted are the complete set of codes or do you have few more lines in the script..? As the error says problem in line # 9.
# 6  
Old 03-08-2012
Quote:
Originally Posted by michaelrozar17
Posted are the complete set of codes or do you have few more lines in the script..? As the error says problem in line # 9.
Hi
That is the complete set of code, ends with fi
when I remove the emplty line after fi the error is

Code:
 
mc.sh: line 8: syntax error near unexpected token `fi'
mc.sh: line 8: ` fi'

Thanks
DC
# 7  
Old 03-08-2012
Ok. Then try running as bash -x script_name and tell us the output you get.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Need some Help please with Linux shell script.

we need help with the syntax with this shell script, if you could create this shell script we can donate to a charity etc. we need to set up a directory called user3 inside directory user3 we need to create the following files : afile, anyfile, anotherfile, afiletest, bfile. bfiletest, cfile,... (3 Replies)
Discussion started by: cometboy
3 Replies

2. Shell Programming and Scripting

Script Shell Linux

Hello, Please, how can I complete this script: Thank you (2 Replies)
Discussion started by: chercheur857
2 Replies

3. Homework & Coursework Questions

Linux Shell Script

Hi Guys I am new to Linux Shell Scripting . Can any one help me with this Task...files are attached for reference Task 1: write a script to generate a large size report file MX0002_new.XML by using the template MX0001_new.XML. Shell script is recomended, and it can run on Linux without... (2 Replies)
Discussion started by: samy_1811
2 Replies

4. Shell Programming and Scripting

Need help! Linux shell script

Hi all, I am trying to make a Nodemanager work in RHEL 5 I got this script from 'oraclemiddleware.wordpress.com', and made appropriate changes to suit my weblogic installation. I keep getting the error, "line 82: syntax error: unexpected end of file". I have checked every line to make sure all... (4 Replies)
Discussion started by: chakrv1
4 Replies

5. Shell Programming and Scripting

PLEASE HELP! LINUX BASH SHELL SCRIPT

PLEASE HELP! NEED LINUX SCTIPT Need to write a bash shell script to show information of employees of a department from a company data set. The script should accept a project number (1/2/3/10/20/30) and output * the name of the project * the name of the manager of the controlling... (1 Reply)
Discussion started by: help123
1 Replies

6. Linux

Error executing shell script in Linux

Hi, I have following shell script code : ------------------------------------------------------------------ #!/bin/bash SCRIPTS_DIR="/scriptsDir1" # tables login/password APIL_USER="uname/pswd" I2_USER="uname/pswd" # Database DB="db1" cd "$SCRIPTS_DIR/scriptsDir2" sqlplus... (1 Reply)
Discussion started by: Chaitrali
1 Replies

7. Shell Programming and Scripting

Error executing shell script in Linux

Hi, I have following shell script code : ------------------------------------------------------------------ #!/bin/bash SCRIPTS_DIR="/scriptsDir1" # tables login/password APIL_USER="uname/pswd" I2_USER="uname/pswd" # Database DB="db1" cd "$SCRIPTS_DIR/scriptsDir2" sqlplus... (2 Replies)
Discussion started by: Chaitrali
2 Replies

8. Shell Programming and Scripting

Linux Shell Script

I'm interested in writing a (hopefully) simple Linux Shell Script. Upon shutdown of the system (or upon reboot), I would like the script to automatically reset any changes made during that session. This includes files saved to the hard disk as well as any configuration changes. I would also like... (6 Replies)
Discussion started by: wilson735
6 Replies

9. Shell Programming and Scripting

help with linux shell script

HI im a novice with shell scripts but i need help with a random script I have this folder filled with 500 different file names... I need help creating a script that will take each filename and make a new folder named that filename and then move that file into the newly created folder. Then the... (1 Reply)
Discussion started by: emachala
1 Replies

10. UNIX for Dummies Questions & Answers

Linux Shell Question: how to print the shell script name ?

Suppose I have a script named "sc.sh" in the script how to print out its name "sc.sh"? (3 Replies)
Discussion started by: meili100
3 Replies
Login or Register to Ask a Question