LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Constant errors in .bash_profile and startx does not load automatically (https://www.linuxquestions.org/questions/linux-newbie-8/constant-errors-in-bash_profile-and-startx-does-not-load-automatically-830265/)

mmoi5 09-04-2010 12:24 AM

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

smoker 09-04-2010 02:47 AM

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.

grail 09-04-2010 02:59 AM

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 ]

mmoi5 09-04-2010 05:01 AM

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

mmoi5 09-04-2010 05:05 AM

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.......

crts 09-04-2010 06:17 AM

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.

grail 09-04-2010 09:41 AM

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?

mmoi5 09-04-2010 10:16 AM

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.


All times are GMT -5. The time now is 02:17 AM.