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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-14-2009, 06:37 AM
|
#1
|
|
Member
Registered: Jul 2009
Location: South Africa
Posts: 38
Rep:
|
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
|
|
|
|
09-14-2009, 06:52 AM
|
#2
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,711
|
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)].
|
|
|
|
09-14-2009, 07:00 AM
|
#3
|
|
Member
Registered: Jul 2009
Location: South Africa
Posts: 38
Original Poster
Rep:
|
hmm my bash is not very good
can you gimme an example?
|
|
|
|
09-14-2009, 07:18 AM
|
#4
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,711
|
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
|
|
|
|
09-14-2009, 07:28 AM
|
#5
|
|
LQ Veteran
Registered: Sep 2003
Location: the Netherlands
Distribution: lfs, debian, rhel
Posts: 8,711
|
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.
|
|
|
|
09-14-2009, 08:12 AM
|
#6
|
|
Member
Registered: Jul 2009
Location: South Africa
Posts: 38
Original Poster
Rep:
|
aah that makes sense
Thanks alot

|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 02:38 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|