LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-12-2014, 06:11 AM   #16
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203

Hmm.. Then are you sure you don't have something in your ~/.bashrc or similar startup script?

Try creating a fresh user (or, hell, try while beeing root -- just be sure it's a login shell, so do "su - root", or "sudo bash --login") and see if the JAVA_HOME variable still has problems.. The point is to pin-point if it's a system-wide script problem or just some script that gets executed when you login..
 
Old 01-12-2014, 06:22 AM   #17
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by Smokey_justme View Post
@jlinkels: Echo will add an <LF> character by default at the end (without the -n option) .. It has nothing to do with the problem at hand and it doesn't really matter in rknichols code (which was focused on the inner echo fixing the <CR> in the variable).. Moreover, -n option will not suppress any <LF>'s added by you, it will only not add a new one..
I think I had a serious off-day. Too bad some replies quoted me, so it doesn't even make sense to delete my posts.

jlinkels
 
Old 01-12-2014, 06:32 AM   #18
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
Pff, if I had a nickle for each time I made this kind of mistakes... Just don't worry about it...
 
Old 01-12-2014, 09:03 AM   #19
eRJe
Member
 
Registered: May 2005
Location: Netherlands
Distribution: Slackware 14.1 Kernel 3.12.1
Posts: 103

Original Poster
Rep: Reputation: 16
@jlinkels; I'm just glad that people take the effort to help :-)

I still haven't found where $JAVA_HOME is getting the return carriage but I have double proof, I think...

Code:
root@RJ-Server:/etc# echo $JAVA_HOME
/usr/lib64/java
root@RJ-Server:/etc# echo $MAIL
/var/mail/root
root@RJ-Server:/etc# echo $MAIL blaaaaat
/var/mail/root blaaaaat
root@RJ-Server:/etc# echo $JAVA_HOME blaaaat
 blaaaat64/java

root@RJ-Server:~# ln -s $JAVA_HOME java
root@RJ-Server:~# ln -s $MAIL mail

ls -al

lrwxrwxrwx  1 root root       16 Jan 12 16:00 java -> /usr/lib64/java\r
lrwxrwxrwx  1 root root       14 Jan 12 16:00 mail -> /var/mail/root
$
the \r is causing my pain, right? I really don't understand how it is added...
 
Old 01-12-2014, 11:07 AM   #20
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,777

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
vi (and its clones) will detect that the file has DOS-style CR-LF line endings and will work in that mode, saving the file in that same format. If you look at the status line at the bottom of the screen when the file is first read, you will see "[dos]". To save such a file with Unix-style line endings, you would need to change the fileformat before saving it:
Code:
:set ff=unix
Or, you could just run the dos2unix command on the file to change its line endings.

Last edited by rknichols; 01-12-2014 at 11:08 AM.
 
1 members found this post helpful.
Old 01-12-2014, 11:10 AM   #21
Smokey_justme
Member
 
Registered: Oct 2009
Distribution: Slackware
Posts: 534

Rep: Reputation: 203Reputation: 203Reputation: 203
The presence of the <CR>(\r) is clear..

Just to be sure, run the following (notice the first dot and space after? that's mandatory):
Code:
. /etc/profile.d/jdk.sh
echo $JAVA_HOME blabla
If the carriage return is still present then this is your affected file, so run the following (as root) to fix it:
Code:
cd /etc/profile.d
mv jdk.sh jdk.sh.orig
tr -d '\r' < jdk.sh.orig > jdk.sh
chmod a+x jdk.sh
chmod a-x jdk.sh.orig
Then rerun the first code-block from this post and insure it's fixed.

LE: Or do what rknichols said.. But Slackware doesn't have dos2unix command (use my code instead if you don't know how to use vi)

Last edited by Smokey_justme; 01-12-2014 at 11:13 AM.
 
1 members found this post helpful.
Old 01-12-2014, 08:06 PM   #22
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
well you cant remove the <CR> at the source but yes as the way suggested using "tr -d".
 
Old 01-13-2014, 04:19 PM   #23
eRJe
Member
 
Registered: May 2005
Location: Netherlands
Distribution: Slackware 14.1 Kernel 3.12.1
Posts: 103

Original Poster
Rep: Reputation: 16
Problem is solved! Thanks everyone for helping.

I used @rknichols trick to set vim with the right properties and then saved the file.

@Smokey_justme thanks for your suggestion and the little coding. That got me a little step further in understanding things.

Thanks!
Robbert

ps I still don't understand how that file got the carriage. I'm very sure I did not have that on a Windows computer. I think the file in the java package must have already contained the error.

Last edited by eRJe; 01-13-2014 at 04:23 PM.
 
  


Reply



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
Avoid carriage return until ^M is found (CentOS 6, bash 4.1) gacanepa Linux - Newbie 2 10-25-2013 12:34 PM
bash script read command issue with carriage return itamarm Linux - General 3 06-17-2013 07:37 AM
carriage return mike2008 Linux - Newbie 3 10-15-2009 12:03 AM
variable length string using GD (word wrap, carriage return, word/character count)? frieza Programming 1 02-14-2009 05:21 PM
BASH: instad of echo-ing, I just want to assing to a bash variable... how?? rylan76 Linux - Newbie 9 11-28-2008 08:46 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:11 AM.

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