File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes Reading Variables and forming a directory in LINUX Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Reading Variables and forming a directory in LINUX" Watch "Reading Variables and forming a directory in LINUX" New topic
Author

Reading Variables and forming a directory in LINUX

Rajesh MadhanGopal
Ranch Hand

Joined: Jan 19, 2006
Posts: 69
Hi,

I need to know how to form a directory by reading a value from the property file, the value that is being read from the property file is used to construct a directory name.

e.g) variable read from property file is \usr\local\csr is set in a variable $dirc

now, i need to form a complete name by concatinating $dirc with \cpc\bin\run.sh

this doesnt quite seem to work with a normal $dirc\cpc\bin\run.sh

would appreciate if someone could help me on this.

Thanks<br />Rajesh
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15961
    
  19

No it wouldn't. You're trying to create Windows directory paths. In Linux, the backslash character ("\") is an escape character that indicates that the character to the right of it is to be interpreted in a special way (depending on what that character is), so the actual filename you're referencing isn't what you think it is.

In Linux and Unix, you use forward (real) slashes to separate path components, not backslashes. So the proper form is:

$dirc/cpc/bin/run.sh

I think you have another problem as well, but I'm not sure. Doing the paths wrong is problem enough.


Customer surveys are for companies who didn't pay proper attention to begin with.
Rajesh MadhanGopal
Ranch Hand

Joined: Jan 19, 2006
Posts: 69
Hey Tim,

Thanks for the reply, i had meant the forward slash but typed in the other one. Anyways, i guess putting them inside of curly brackets helped me solve the actual issue.

${dir}/abc/def/ is the way to go i guess..
Lorand Komaromi
Ranch Hand

Joined: Oct 08, 2009
Posts: 276
Don't hardcode / or \, use File.separatorChar!


OCJP 6 (93%)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading Variables and forming a directory in LINUX
 
Similar Threads
setting Java parameters on startup
classpath
K&B - Practice Exams book - Full Exam II - Question 21
classpath.
Download CSV file from apllication server