LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-18-2010, 03:50 PM   #1
xri
Member
 
Registered: Aug 2002
Distribution: Slackware 14.2, Archlinux
Posts: 283
Blog Entries: 11

Rep: Reputation: 41
Question source bashrc -> syntax error: unexpected end of file


I don't remember making any changes on any of these files on my account:
.bashrc
.bash_profile
.bash_logout
However, when I log into my slack box through ssh from another place, I get this error message:
Quote:
-bash /home/xri/.bashrc syntax error: unexpected end of file
-bash /home/xri/.bash_profile syntax error: unexpected end of file
Once inside my slackbox, after source <.bashrc | .bash_profile | .bash_logout>, I get the same error message, with all of them.
I checked them all, inside vim, which highlights the code, and I did not find anything unusual.

This is puzzling. I don't know what to look at.Could somebody give me a hint?

Thanks for reading this.
 
Old 12-18-2010, 04:00 PM   #2
rg3
Member
 
Registered: Jul 2007
Distribution: Fedora
Posts: 527

Rep: Reputation: Disabled
Can you paste the actual file contents? That would be a good start.
 
Old 12-19-2010, 10:59 AM   #3
xri
Member
 
Registered: Aug 2002
Distribution: Slackware 14.2, Archlinux
Posts: 283

Original Poster
Blog Entries: 11

Rep: Reputation: 41
course, sorry

Quote:
# ~/.bashrc
#
# see /etc/bashrc for a complete description how all bash source files
# are related and used on this box

# Source system-wide aliases and functions
if [ -f /etc/bashrc ]; then
source /etc/bashrc
fi

# --- Local/Personal environment variables ---
# define bash prompts, non-X text editors, etc.
unset MAILCHECK

# --- Local aliases ---
# Listing and cd
alias ll='ls -lh --color|most'
alias la='ls -lah --color|most'
alias lt='ls -ltrh --color|most'
alias ls='ls --color'
alias l='ls -l --color'
alias d='pwd'
alias dow='cd /home/xri/downloads'
alias co='cd /home/xri/const'
alias pr='cd /home/xri/newsoftware'
alias is='cd /home/xri/isos'
alias fl='cd /home/xri/.fluxbox'
alias ..='cd ..'
alias cl='clear'

# Locally
alias find='find . -iname'
alias ft='find . -ctime'
alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd '
alias pgrep='pgrep -l'

# On the net
alias lya='lynx wiki.archlinux.org'
alias lyn='lynx www.linuxquestions.org'
alias g='google -search=linux'
alias wk='wikipedia'

# This system
alias mo='mount|grep -v logi|grep -v tmp|grep -v usb|grep -v fuse'
alias ml='mount|grep logi'
alias mf='mount|grep fuse'
alias df='df -h'
alias ram='free -m'

# This file
alias cm='vim ~/.bashrc'
alias cmm='source ~/.bashrc'

#################################################
# --- Local functions ---

export PATH=$PATH:/usr/sbin:/home/xri/newsoftware
complete -cf sudo

#################################################
# Necessary for now
if [ -f /home/xri/personal/somedata.kdb.lock ]; then
rm /home/xri/personal/somedata.kdb.lock
fi
##################################################
# More important actions
alias m='msgc'
alias n='notesshort'
alias cla='sgc-claws'
alias comp='src2pkg'

##################################################
# Activated at startup
Quote:
# ~/.bash_profile
#
# see /etc/bashrc for a complete description how all bash source files
# are related and used on this box

# Source Local/Personal aliases and functions
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi

# Source /usr/local/bin/bash_login
if [ -x /usr/local/bin/bash_login ]; then
/usr/local/bin/bash_login
fi

# --- Local/Personal startup programs ---
Quote:
# ~/.bash_logout
#
# see /etc/bashrc for a complete description how all bash source files
# are related and used on this box

# Source /usr/local/bin/bash_logout
if [ -x /usr/local/bin/bash_logout ]; then
/usr/local/bin/bash_logout
fi


rm /home/ele/algo/trivialidades.kdb.lock
I haven't edited any of them recently, let alone all three of them.
However, out of a sudden, I'm getting these error messages:

Quote:
bash-4.1$ source .bashrc
bash: ./.bashrc: line 73: syntax error: unexpected end of file
bash-4.1$ source .bash_profile
bash: ./.bash_profile: line 16: syntax error: unexpected end of file
bash-4.1$ source .bash_logout
bash: ./.bash_logout: line 13: syntax error: unexpected end of file
 
Old 12-19-2010, 11:23 AM   #4
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,899

Rep: Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579Reputation: 579
Is this all on one line?:
alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd'
If not, try making it so. Another thing you might try is having a an empty newline at the end of each file -have you upgraded bash recently?
 
Old 12-19-2010, 01:11 PM   #5
T3slider
Senior Member
 
Registered: Jul 2007
Distribution: Slackware64-14.1
Posts: 2,367

Rep: Reputation: 841Reputation: 841Reputation: 841Reputation: 841Reputation: 841Reputation: 841Reputation: 841
Does that line that gnashley noted actually work? You're using a single quote to denote the contents of the alias but using the same single quote within the alias definition...I would think it would be breaking in and out of the alias definition.
 
Old 12-19-2010, 01:29 PM   #6
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,853

Rep: Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725
Well I just tried temporarily replacing my bashrc and bash_profile with the ones you posted and they work fine ( except any missing programs/folders/files that you may have installed that I don't ) maybe the files themselves have been corupted, I just tried changing the line ends to dos type via the todos command and now get the same errors as you are getting so I guess thats a good place to start.
 
Old 12-19-2010, 02:06 PM   #7
jamesf
Member
 
Registered: Dec 2004
Location: USA
Distribution: Slackware 12, Slackware64 14.2
Posts: 236
Blog Entries: 1

Rep: Reputation: 56
Quote:
Originally Posted by T3slider View Post
Does that line that gnashley noted actually work? You're using a single quote to denote the contents of the alias but using the same single quote within the alias definition...I would think it would be breaking in and out of the alias definition.
Yes, it appears to (but the inner quotes are all stripped from the alias:
Code:
bash-4.1$ alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd'
bash-4.1$ alias
alias me='echo rig && uname -n && echo ME && whoami && echo LOCATION && pwd'
bash-4.1$ me
rig
darkstar
ME
james
LOCATION
/home/james
bash-4.1$
He's sourcing /etc/bashrc in his first two scripts, but on my machine:
Code:
bash-4.1$ cat /etc/bashrc            
cat: /etc/bashrc: No such file or directory
bash-4.1$
But I bet that Keith Hedger (above) is onto something with the line endings.
 
Old 12-19-2010, 03:15 PM   #8
xri
Member
 
Registered: Aug 2002
Distribution: Slackware 14.2, Archlinux
Posts: 283

Original Poster
Blog Entries: 11

Rep: Reputation: 41
Quote:
Originally Posted by gnashley View Post
Is this all on one line?:
alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd'
If not, try making it so. Another thing you might try is having a an empty newline at the end of each file -have you upgraded bash recently?
Thanks for the input, all of you.
  1. The line actually works as it is (I always use it, and I'm using it right now).
  2. I have not upgraded bash recently. It's all original slack, with some slackbuilds on top of it.
  3. I have not touched the files in question with any DOS or Windows tool at all. However, I'm very interested in following on Keith Hedger's idea, although I don't know how to do that at this point.

By the way, I'm uploading a snapshot of all my installed programs, and when they were installed. Sorry, I could not paste the content here ('too many characters').
Attached Files
File Type: txt installed_packages_list_19_12_2010_16_04_43.txt (52.1 KB, 38 views)
 
Old 12-19-2010, 03:50 PM   #9
mRgOBLIN
Slackware Contributor
 
Registered: Jun 2002
Location: New Zealand
Distribution: Slackware
Posts: 999

Rep: Reputation: 229Reputation: 229Reputation: 229
Code:
fromdos < oldfile > newfile
Oh and you can check the line endings with
Code:
cat -A some_file

Last edited by mRgOBLIN; 12-19-2010 at 03:52 PM.
 
1 members found this post helpful.
Old 12-19-2010, 04:54 PM   #10
Keith Hedger
Senior Member
 
Registered: Jun 2010
Location: Wiltshire, UK
Distribution: Linux From Scratch, Slackware64, Partedmagic
Posts: 2,853

Rep: Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725Reputation: 725
You can also check for odd characters that don't get printed by
Code:
hexdump -C .bashrc

00000000  23 21 2f 62 69 6e 2f 62  61 73 68 0a 23 20 7e 2f  |#!/bin/bash.# ~/|
00000010  2e 62 61 73 68 72 63 3a  20 65 78 65 63 75 74 65  |.bashrc: execute|
00000020  64 20 62 79 20 62 61 73  68 28 31 29 20 66 6f 72  |d by bash(1) for|
00000030  20 6e 6f 6e 2d 6c 6f 67  69 6e 20 73 68 65 6c 6c  | non-login shell|
...
the 0a is the correct linux line ending, if its a dos line ending it will be 0d 0a
 
1 members found this post helpful.
Old 12-22-2010, 08:29 AM   #11
xri
Member
 
Registered: Aug 2002
Distribution: Slackware 14.2, Archlinux
Posts: 283

Original Poster
Blog Entries: 11

Rep: Reputation: 41
Sorry for some delay to post again. The last few days have been hectic.

fromdos < .bashrc > newfile
source newfile gives me the same error message

cat -A .bashrc
every single line (including a couple of final empty lines) ends with "$"

hexdump -C .bashrc
the output shows several "0a" but no "0d 0a".
 
Old 12-22-2010, 08:40 AM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
You could try progressively commenting out lines in the hope of identifying the problem line(s). .bash_logout, being the shortest would be a good one to start with.
 
1 members found this post helpful.
Old 12-22-2010, 09:01 AM   #13
xri
Member
 
Registered: Aug 2002
Distribution: Slackware 14.2, Archlinux
Posts: 283

Original Poster
Blog Entries: 11

Rep: Reputation: 41
I found something else. The problem seems to be on the "if" statements.

Quote:
f [ -f /etc/bashrc ]; then
source /etc/bashrc
fi
Quote:
if [ -f /home/xri/personal/somedata.kdb.lock ]; then
rm /home/xri/personal/somedata.kdb.lock
fi

When I comment out both, then I get no error messages.
If I uncomment either one, then I get the same error message shown on the initial post.

Why? Are they incorrect? The first one came with the freshly installed Slack and never gave me problems before.
 
Old 12-22-2010, 09:05 AM   #14
xri
Member
 
Registered: Aug 2002
Distribution: Slackware 14.2, Archlinux
Posts: 283

Original Poster
Blog Entries: 11

Rep: Reputation: 41
catkin, I just found your post; while you were writing it, I was doing exactly what you were suggesting
The only thing, I was doing it on .bashrc.
 
Old 12-22-2010, 09:14 AM   #15
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,577
Blog Entries: 31

Rep: Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197Reputation: 1197
Try running unalias -a before sourcing, with the if-fi blocks uncommented.
 
1 members found this post helpful.
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] syntax error: unexpected end of file adidoosh100 Programming 14 08-08-2010 12:44 AM
why i get syntax error: unexpected end of file ?? freephys Linux - Newbie 3 06-24-2010 09:03 AM
syntax error: unexpected end of file ygdrazil Linux - Newbie 3 07-23-2009 05:00 AM
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

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 09:22 PM.

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