LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   export Warnings/Errors at Bash Login - How to trace down issues? (https://www.linuxquestions.org/questions/linux-newbie-8/export-warnings-errors-at-bash-login-how-to-trace-down-issues-820758/)

jspeaks 07-19-2010 01:27 PM

export Warnings/Errors at Bash Login - How to trace down issues?
 
We are getting

-bash: export: `/usr/java/default': not a valid identifier

messages when we login as root to one of our server. This started occurring after a consultant installed software on the server. I have looked around in .bashrc, etc. for the error path so I can remove it, but can't seem to locate it. Does anyone have any tips on how to locate script line where this is being included, and/or trace the login procedure to find the culprit?

Tinkster 07-19-2010 01:58 PM

Look for a line
Code:

export $<something>

catkin 07-20-2010 05:08 AM

Quote:

Originally Posted by jspeaks (Post 4038411)
... any tips on how to ... trace the login procedure to find the culprit?

Bash's use of Bash Startup Files is described here.

Different files are used for logon, interactive and non-logon bash sessions so you can home in on the problem line by considering if it happens only for logon sessions.

If that isn't enough, you can add a line at the beginning and end of each start up file, something like
Code:

echo '.bashrc starting'
Beware that start up files may run other files; especially /etc/profile may run many files from the /etc/profile.d directory.

Another technique is to put set -xv in the startup files; doing so in the global files (under /etc) will affect all users. Doing so in any start up file may cause breakage. So better to do so in the user's own bash start up file(s) first!

i92guboj 07-20-2010 05:53 AM

If you don't want to modify anything you could just run

Code:

bash -x ~/.bashrc
As the problematic user (root in this case). That will help you track down the issue. The output can be a bit complicated though, depending on how complex your ~/.bashrc file is.

But, for the look of it, I think that you are either missing the left-most part of a variable declaration. It should usually look like this:

Code:

VAR="value"
# or in this case probably
export VAR="value"

Maybe your "admin" just wrote something like

Code:

export /whatever/value
Which doesn't make any sense and is not a correct bash syntax. The right solution will vary depending on what the intended purpose for that line was. Removing or commenting it should take rid of the warning though. It shouldn't have any side effect other than that though, since that line is incorrect anyway and it doesn't declare anything or do any other thing other than spitting an error message.

i92guboj 07-20-2010 05:55 AM

Thinking about it, your problem might be something more like this:

Code:

VAR=/my/value
export $VAR

In this case, bash substitutes $VAR by '/my/value', resulting in an incorrect export declaration as I said in the previous post. Simply removing the '$' will work.

catkin 07-20-2010 06:12 AM

On further reflection this might be a simpler way to track down the offending line:
Code:

grep '/usr/java/default' /etc/profile ~/.bash_profile ~/.bash_login ~/.profile /etc/profile.d/*.sh

Tinkster 07-20-2010 01:33 PM

Quote:

Originally Posted by i92guboj (Post 4039322)
Thinking about it, your problem might be something more like this:

Code:

VAR=/my/value
export $VAR

In this case, bash substitutes $VAR by '/my/value', resulting in an incorrect export declaration as I said in the previous post. Simply removing the '$' will work.


Heh. Which is pretty much what I said in less words ;D

jspeaks 07-21-2010 10:07 AM

Catkin thanks for that link to "Bash's use of Bash Startup Files". That was the tip I needed to locate the /etc/profile and remove 2 export statements that were causing the problem. Thanks to everyone else for the additional information.

Jaye


All times are GMT -5. The time now is 07:58 AM.