Using java process to write file failes
Using java process to write file failes
- Subject: Using java process to write file failes
- From: Wolfram Stebel <email@hidden>
- Date: Wed, 07 Sep 2005 15:14:35 +0200
Hi all,
i'm trying to extract some data from my apache logs.
the following code creates a file (owner appserver:admin) first.
With the "more | grep" i try to append data to the file.
This gives me the error "access denied", so i think, the Process p is not
running under "appserver" user.
How can i do such shell commands under the correct user?
Clearly, in development the code does the job without access problems.
Thanks for any pointers
Wolfram
Code in my WOComponent:
// write new log file
File newLog = new File ( clientLogData );
newLog.delete ();
newLog.createNewFile ();
// construct command for process
String command1 = "more " + monthLogFile + " | grep /" + clientAlias + "/ >>
" + clientLogData;
try
{
// execute command
Process p = Runtime.getRuntime ().exec ( command1 );
int terminated = p.waitFor ();
if ( NSLog.debugLoggingAllowedForLevel ( NSLog.DebugLevelDetailed ) )
{
NSLog.out.appendln ( "terminated (0=OK) : " + terminated );
BufferedReader err = new BufferedReader( new InputStreamReader (
p.getErrorStream () ) );
NSLog.out.appendln ( "error: " + err.readLine () );
}
}
....
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden