• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading Variables and forming a directory in LINUX

 
Rajesh MadhanGopal
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18100
51
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rajesh MadhanGopal
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't hardcode / or \, use File.separatorChar!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic