Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Reading Variables and forming a directory in LINUX

 
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.
 
Saloon Keeper
Posts: 22664
153
Android Eclipse IDE Tomcat Server Redhat Java 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..
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't hardcode / or \, use File.separatorChar!
 
Yeah, but how did the squirrel get in there? Was it because of the tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic