Find the answer to your Linux question:
Results 1 to 4 of 4
I am getting an "unexpected end of file" error while executing the script.Code is given below. please help me to solve it out FILE="$1" exec 3<&0 exec 0<$FILE while read ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    2

    Error in shell script

    I am getting an "unexpected end of file" error while executing the script.Code is given below. please help me to solve it out

    FILE="$1"

    exec 3<&0
    exec 0<$FILE
    while read line
    do
    echo $line
    if [ $line == "balaji" ]
    then
    echo hai
    fi
    done
    exec 0<&3

    exit 0

  2. #2
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    Can please, explain bit more about your problem?What are you trying out with the script?
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    2
    Hi Lakshmi,
    My requirement is to read the file line by line.So i am sending the file name as argument.If any of the line in the file matches
    "#student layout" i have to skip next 3 lines and display the other line.Code is given below.
    FILE="$1"
    key=" "
    i=0
    exec 3<&0
    exec 0<$FILE
    while read line
    do
    echo $line
    if [ $line == "#student layout" ]
    then
    for i in 1 2 3
    do
    read line
    done
    fi
    done
    exec 0<&3

    exit 0
    Can you tell me is there any syntax error in my code.
    Now i am getting an error -"syntax error near unexpected token 'do in line no12."
    I am working on Salaris.

  4. #4
    Just Joined!
    Join Date
    May 2005
    Posts
    48
    On the 5th line
    exec 0<$FILE
    exec 0<"$FILE" #try with quotes



    look here for reference

    hth & gl

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...