LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-04-2010, 01:24 AM   #1
mmoi5
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Rep: Reputation: 0
Constant errors in .bash_profile and startx does not load automatically


Hello one and all.
I am already grateful for coming across this site not to mention the delight in reading many earlier responses that have aided me in resolving issues with linux installations.

Here is to hoping that you guys would aid once again.

I have installed Damn Small Linux on an old laptop.
Every boot reports that the SSH has loaded as I have configured it to do so but does not load startx as instructed in .bash_profile.

After bootup, the following is reported by the system.

-bash: /home/dsl/.bash_profile: line 12: syntax error: unexpected end of file

This is the content of the .bash_profile
#!/bin/bash
export IRCNICK=DSL
export DISPLAY=:0
SSH=`env | grep SSH_CONNECTION`
RUNLEVEL=`runlevel|cut -f2 -d' '`
if [-z"$SSH"];then
if[$RUNLEVEL -eq 5];then
startx
fi
fi


I have tried to # entries and realized that I had to # starting from the IF statement and all the way to the end in order to eliminate the error.

Startx will load properly after boot but will not load automatically as a part of the boot.

I can also load startx from a SSH session but the minute I terminate the SSH session the GUI unloads back to prompt.

If you know were I have gone wrong I would greatly appreciate it if you point it out.

In advance, thanks....... Mmoi5
 
Old 09-04-2010, 03:47 AM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 249Reputation: 249Reputation: 249
Why not quote the variable $RUNLEVEL ?

Code:
if["$RUNLEVEL" -eq 5];then
In fact you could replace the two ifs with one :
Code:
if [ -z "$SSH" ] && [ "$RUNLEVEL" -eq 5 ]
then
  startx
fi
But I don't see what you're trying to do with the -z "SSH"
My env shows no SSH_CONNECTION entry, so that test will always be true, in which case you only need the runlevel test.

Last edited by smoker; 09-04-2010 at 03:57 AM.
 
Old 09-04-2010, 03:59 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
So two things spring to mind:

1. Obviously damn small doesn't use inittab where you can say start runlevel 5 and that will tell startup scripts to launch X??

2. The test brackets [] require space between them and the next characters, as is shown in smoker's examples. So make sure you have a space after [ and before ]
 
Old 09-04-2010, 06:01 AM   #4
mmoi5
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
nice ideas but to no avail

Running bash -v .bash_profile reports the following:

#!/bin/bash
export IRCNICK=DSL
export DISPLAY=:0
SSH=`env | grep SSH_CONNECTION`
env | grep SSH_CONNECTION
RUNLEVEL=`runlevel|cut -f2 -d' '`
runlevel|cut -f2 -d' '
if [ -z "$SSH" ] && [ "$RUNLEVEL" -eq 5 ]
then
startx
fi
.bash_profile: line 10: syntax error: unexpected end of file

Last edited by mmoi5; 09-04-2010 at 06:08 AM.
 
Old 09-04-2010, 06:05 AM   #5
mmoi5
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
nice ideas but to no avail

Thank you for your ideas.

I have tried as you mentioned "Smoker" (both variations) and the "syntax error: unexpected end of file " still comes up.

I have even tried to remove the -z $SSH and just go with the RUNLEVEL but same result as previoulsy.

And "Grail", DSL does have an inittab file and I edited it previously to support the auto logon, but can you please elaborate a little more regarding your idea of using inittab to initiate startx ?

In all cases if startx is triggered from prompt after boot it loads nicely but not automatically.


In advance thanks.......

Last edited by mmoi5; 09-04-2010 at 06:07 AM.
 
Old 09-04-2010, 07:17 AM   #6
crts
Senior Member
 
Registered: Jan 2010
Posts: 1,606

Rep: Reputation: 448Reputation: 448Reputation: 448Reputation: 448Reputation: 448
Hi,

1.) Please use code tags.
[CODE]
code goes here
[/CODE]

2.) I notice that in your first post the error is claimed in line 12. There is no line 12 in your example. So I have to assume that the error in your second example might also not be located in line 10. Is this the complete .bash_profile?

3.) I see a windows logo in the left pane of your posts. Is there any chance that you did modify this files using windows? This might have screwed up the line endings.
 
Old 09-04-2010, 10:41 AM   #7
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,256

Rep: Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686Reputation: 2686
Quote:
And "Grail", DSL does have an inittab file and I edited it previously to support the auto logon, but can you please elaborate a little more regarding your idea of using inittab to initiate startx ?
Normally in inittab you will find the following line:
Code:
id:3:initdefault:
The 3 in the above is the chosen runlevel. So if you set this to the number 5 it will tell the system to run all applications up until the fifth
runlevel.

Then if you look in your /etc directory there will be either a rc.d or rcN.d (where N is a number from 1 - 5).
Look in the rc5.d directory and this will show you all files that start at that runlevel. Then depending on which manager you are running will depend
on which file is launched. Could be one of the following:

gdm
kdm
xdm

There are others, but if you look in there you will probably figure out which one it is.

Let us know how you get on?
 
Old 09-04-2010, 11:16 AM   #8
mmoi5
LQ Newbie
 
Registered: Sep 2010
Posts: 5

Original Poster
Rep: Reputation: 0
Problem solved

Thank you for the response.
Got it working in the end with help from all of you.

This feed back is addressed to all that have responded.

crts:

I have used putty installed on MS windows to initiate some of the changes. I thought that all changes via putty or a SSH terminal inherit local settings for the user on the destination machine, or did I get that wrong?

Either way, I have started from scratch by rebuilding the entire script library for that machine so as to get rid of any mysterious windows "ENTER" entries at the end of each line. And it seems to work fine after having done that in addition to adopting grail's and smoker's tips.

Grail:
Your idea to utilise inittab did work, but I believe it was a work around to the problem and not a direct fix to the issue, but thank you for a very good tip that I will surely utilize in the future many a times.

Smoker:
Your tip to join the ifs with && simplified troubleshooting.

Thank you all for a professional and curtious assistance.
 
  


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
startx automatically free_andrew Slackware 17 11-10-2014 10:40 AM
[SOLVED] Constant errors in .bash_profile and startx does not load automatically mmoi5 Linux - Newbie 1 09-04-2010 07:33 AM
no ~.bashrc ~.bash_profile. Pythonpath always bringing errors when using compiz, etc. Romanus81 Slackware 3 05-22-2008 11:29 PM
startx automatically devavictrix Linux - Newbie 5 03-13-2006 11:44 PM
errors in .bash_profile psyklops Linux - General 4 09-03-2003 12:40 AM


All times are GMT -5. The time now is 10:46 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration