Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2006

Tip: Looking for answers? Try searching our database.

Changing a log file's attributes such as the owner property

Thread view: 
marcwentink@hotmail.com - 06 Apr 2006 14:19 GMT
I have been looking how to change the file attributes inside java, I
want to make a java program that would give certain Linux rights to the
created file. But it seems this is impossible, which is logical if you
take into account that java should be platform independant, and
ownership is typical a unix/linux property.

Right?

Nevertheless, if I try to make a log file it is only readable for the
linux user that started the java application. And this not always the
user that will try to read the log file. So what could I do?

Marcus Wentink
Gordon Beaton - 06 Apr 2006 14:37 GMT
> Nevertheless, if I try to make a log file it is only readable for the
> linux user that started the java application. And this not always the
> user that will try to read the log file. So what could I do?

The default file creation mode is determined by the user's umask. If
you want to change the default file permissions, change the umask in
the user's shell before running the application. "man umask" will tell
you more.

Or use Runtime.exec() after creating the file to invoke a linux
specific utility (chmod) to let other users read the file.

If the file is (already) readable by members of the file's *group*,
you might also add (specific) users to that group so they can read the
file.

/gordon

Signature

[  do not email me copies of your followups  ]
g o r d o n + n e w s @  b a l d e r 1 3 . s e

marcwentink@hotmail.com - 06 Apr 2006 14:53 GMT
Gordon Beaton:

> Or use Runtime.exec() after creating the > file to invoke a linux

Ok, that's a good idea. Thank you very much

And if I use it like +/- this code below 'chmod' will only be used once
every java VM machine call.

class LogIt
{
  private static File file;
  private static BufferedWriter out;

 static
 {
     open();
     Runtime.exec()    
 }

Marcus Wentink


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.