| | |
Shell Scripting Problem
Please support our Shell Scripting advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Solved Threads: 0
Hey guys ..
I am pretty new to Shell Scripting. I was hoping if some one could help me out with my problem.
I am going with a tutorial for shell scripting. While executing some of the programs and commands I am getting errors. I have also checked other sites and tutorials for the same, but everything seems intact.
Following is the code. When I execute this (after changing the permission - 755), I get an error saying "unexpected end of file", Now I am not sure why this is happening ... please help me out.
Thanks in advance
Regards,
A Kris
I am pretty new to Shell Scripting. I was hoping if some one could help me out with my problem.
I am going with a tutorial for shell scripting. While executing some of the programs and commands I am getting errors. I have also checked other sites and tutorials for the same, but everything seems intact.
Following is the code. When I execute this (after changing the permission - 755), I get an error saying "unexpected end of file", Now I am not sure why this is happening ... please help me out.
Thanks in advance
Regards,
A Kris
Shell Scripting Syntax (Toggle Plain Text)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% help_uni() { echo "Usage: $0 -n -a -s -w -d" echo "Option: These are optional argument" echo " -n name of animal" echo " -a age of animal" echo " -s sex of animal" echo " -w weight of animal" echo " -d demo values (if any of the above options are used" echo " their values are not taken)" exit 1 } if [ $# -it 10];then` help_ani fi while getopts n:a:s:W:d opt do case "$opt" in n) na ="$OPTARG";; a) age ="$OPTARG";; s) sex ="OPTARG";; w) weight ="$OPTARG";; d) isdef = 1;; \?) help_ani;; esac done if[ $isdef -eq 0];then` echo "Animal Name is $na, age is $age, sex is $sex, weight is $weight (user defined mode)" else'' na = "pluto dog" age = 3 sex = male weight = 20kg echo "Animal name is $na, age is $age, sex is $sex, weight is $weight (demo mode)" exit 1 fi'' %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Last edited by John A; Aug 28th, 2008 at 9:14 pm. Reason: added code tags
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
There also seem to be a number of unnecessary backtick characters after a few then and else statements. That could be causing it.
Best wishes,
Mike
Best wishes,
Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
Last edited by Aia; Aug 29th, 2008 at 12:00 am.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Good point. Totally looked right past that. There are spaces to the left and right of all the assignment (=) operators... WOW 
, Mike

, Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
•
•
•
•
Good point. Totally looked right past that. There are spaces to the left and right of all the assignment (=) operators... WOW
, Mike
if [ $# -it 10];then` # ^Wrong ` there # ^Need extra space there # ^Probably 1 (one) and not 10 # ^-lt, not -it. Stands for `is less than' # corrected would be: # if [ $# -lt 1 ]; then # meaning: if not arguments where entered show menu
With that in mind I leave
if[ $isdef -eq 0];then` for you to figure what's wrong with it. echo "Animal name is $na, age is $age, sex is $sex, weight is $weight (demo mode)" exit 1 # Not need it fi'' # Not need it
Last edited by Aia; Aug 30th, 2008 at 11:46 pm.
"If it moves, tax it. If it keeps moving, regulate it, and if it stops moving, subsidize it" - Ronald Reagan
•
•
Join Date: Oct 2007
Posts: 399
Reputation:
Solved Threads: 47
Guess I got mislead by the error message..
I'm surprised a script with so many errors didn't generate a much different one other than unexpected EOF 
,Mike
I'm surprised a script with so many errors didn't generate a much different one other than unexpected EOF 
,Mike
Linux and Unix Tips, Tricks and Individual Advice - The Linux and Unix Menagerie!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
------------------------------------------------------------------------
The greatest viral marketing idea of all time, get your copy of this Free Report now!
![]() |
Similar Threads
- Windows script need help (Computer Science)
- Processing file by file in a txt, and storing the name of the file being processed (Shell Scripting)
- command line arguments problem. (Shell Scripting)
- awk problem (Community Introductions)
- python and shell scripting (Python)
- Shell Scripting problem and related awk issues (Shell Scripting)
- shell scripting help with backup script (Shell Scripting)
- Problem with variables in Windows shell script (Windows NT / 2000 / XP)
Other Threads in the Shell Scripting Forum
- Previous Thread: copying corresponding language files
- Next Thread: Date comparing in Unix shell script
| Thread Tools | Search this Thread |
Tag cloud for Shell Scripting






