LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-14-2009, 06:37 AM   #1
andycol
Member
 
Registered: Jul 2009
Location: South Africa
Posts: 38

Rep: Reputation: 16
bash line 74: syntax error: unexpected end of file help?


hey guys

Please can someone help me
can you see what the error is here in my script

# PPPOE SETUP

echo -e "Would you like to Setup the ADSL?: \c "
read ADSL
if [ "$ADSL?" = "yes" ];
then
echo -e "Default Route?: \c "
read Route?
if [ "Route?" = "yes" ];
then
cat > /etc/sysconfig/network-scripts/ifcfg-ppp0 << CFG
USERCTL=yes
PEERDNS=no
TYPE=xDSL
DEVICE=ppp0
BOOTPROTO=dialup
ONBOOT=yes
PIDFILE=/var/run/pppoe-adsl-0.pid
FIREWALL=NONE
PING=.
PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=0
PERSIST=no
SYNCHRONOUS=no
DEFROUTE=yes
PROVIDER=provider
ETH=eth0
DEMAND=no
USER='andrew@andrew.co.za'
CFG
cat > /etc/ppp/pap-secrets << CFG1
"andrew@andrew.co.za" "*" andrew "*"
####### redhat-config-network will overwrite this part!!! (begin) ##########
####### redhat-config-network will overwrite this part!!! (end) ############
CFG1
else
if [ "Route?" = "no" ];
then
cat > /etc/sysconfig/network-scripts/ifcfg-ppp0 << CFG2
USERCTL=yes
PEERDNS=no
TYPE=xDSL
DEVICE=ppp0
BOOTPROTO=dialup
ONBOOT=yes
PIDFILE=/var/run/pppoe-adsl-0.pid
FIREWALL=NONE
PING=.
PPPOE_TIMEOUT=80
LCP_FAILURE=3
LCP_INTERVAL=20
CLAMPMSS=1412
CONNECT_POLL=6
CONNECT_TIMEOUT=0
PERSIST=no
SYNCHRONOUS=no
DEFROUTE=no
PROVIDER=provider
ETH=eth0
DEMAND=no
USER='andrew@andrew.co.za'
CFG2
cat > /etc/ppp/pap-secrets << CFG3
"andrew@andrew.co.za" "*" andrew "*"
####### redhat-config-network will overwrite this part!!! (begin) ##########
####### redhat-config-network will overwrite this part!!! (end) ############
CFG3
fi


when i run it it goes to the first part saying
"would you like to setup the ADSL'
then i say yes and it says

./adsl: line 74: syntax error: unexpected end of file

any ideas why?

ta
andrew
 
Old 09-14-2009, 06:52 AM   #2
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

You seem to be missing a lot of fi statements. I see three if [......] statements and only 1 fi statement (missing 2).

You also use an if statement right after an else statement, which could be correct but I do believe you want an elif (else if) statement.

Also: Start your script with #!/bin/bash

Hope this helps.

PS: Next time you post a piece of code, put it between code tags ( [ code ] ..... [ /code ] (without the spaces)].
 
Old 09-14-2009, 07:00 AM   #3
andycol
Member
 
Registered: Jul 2009
Location: South Africa
Posts: 38

Original Poster
Rep: Reputation: 16
hmm my bash is not very good

can you gimme an example?
 
Old 09-14-2009, 07:18 AM   #4
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

An example of what?

if - then - else - fi:
Code:
#!/bin/bash
if [[ "X" == "Y" ]]
then
  do action 1
else
  do action 2
fi
Everythime you use if, there should be a closing fi statement.

This might help: Advanced Bash-Scripting Guide

Specific (if/then/else/fi): Chapter 7. Tests
 
Old 09-14-2009, 07:28 AM   #5
anon237
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

I'm not sure if this is what you want/need, but here's your script (shortened and somewhat re-written):
Code:
#!/bin/bash
# PPPOE SETUP

echo -e "Would you like to Setup the ADSL?: \c "
read ADSL
if [[ "$ADSL" == "yes" ]]
then
  # yes was entered for adsl
  echo -e "Default Route?: \c " 
  read Route

  if [[ $Route == "yes" ]]
  then
    # yes was entered for route
    cat > ifcfg-ppp0 << CFG
USERCTL=ABC
PEERDNS=ABC
CFG
    cat > pap-secrets << CFG1
"andrew@andrew.co.za" "*" andrew "*"
####### redhat-config-network will overwrite this part!!! (end) ############
CFG1
  else
  # no was entered for route
    cat > ifcfg-ppp0 << CFG2
USERCTL=XYZ
PEERDNS=XYZ
CFG2
    cat > pap-secrets << CFG3
"andrew@andrew.co.za" "*" andrew "*"
####### redhat-config-network will overwrite this part!!! (end) ############
CFG3
  fi
  # no was eneterd for adsl
fi
Hope this clears things up a bit.
 
Old 09-14-2009, 08:12 AM   #6
andycol
Member
 
Registered: Jul 2009
Location: South Africa
Posts: 38

Original Poster
Rep: Reputation: 16
aah that makes sense

Thanks alot
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash script -----------syntax error: unexpected end of file ArthurHuang Programming 2 05-01-2009 10:29 AM
Bash script - syntax error: unexpected end of file Mr Pink Programming 7 12-19-2008 06:31 AM
Backup Script error "line 31: syntax error: unexpected end of file" eswanepoel General 7 12-07-2007 09:28 AM
/usr/bin/lesspipe: line 223: syntax error: unexpected end of file fakie_flip Linux - Software 1 09-06-2006 02:22 AM
got a syntax error which shows unexpected end of line when tried to run a shell scrip racer_mec Linux - Newbie 1 01-10-2005 01:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:47 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