• Post Reply Bookmark Topic Watch Topic
  • New Topic

grant write access to folder in unix  RSS feed

 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a web application which creates a folder in unix box for a particular request. I was able to create the folder but when other users try to write file to this folder it shows no write permission error. The folder is created by user1 and for user2 wont be able to modify the folder owned by user1.

Is it possible to grant write permission (all users) to the folder from java. I had a look at java.io.File api but could not find anything useful. Any help on this is appreciated.

Thanks,
Rajeev
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can always call (using Runtime.exec or ProcessBuilder) the external program: chmod.
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Rob!

I wrote a small java program to test ProcessBuilder and it worked fine but when i copied the same piece of code into my web application. I am getting exception . The application is deployed on solaris 10 so "chmod: not found " is making me confused. Any thoughts ?






08/11/24 14:03:59 bool : Folder Created !! yay.
08/11/24 14:03:59 Directories: /prj/public/apps/200811020_MSM7600 created

08/11/24 14:03:59 java.io.IOException: chmod: not found
08/11/24 14:03:59 at java.lang.UNIXProcess.forkAndExec(Native Method)
08/11/24 14:03:59 at java.lang.UNIXProcess.<init>(UNIXProcess.java:53)
08/11/24 14:03:59 at java.lang.ProcessImpl.start(ProcessImpl.java:65)
08/11/24 14:03:59 at java.lang.ProcessBuilder.start(ProcessBuilder.java:451)
08/11/24 14:03:59 at com.qualcomm.qct.fadb.factory.RMAJobImpl.createJobFolder(RMAJobImpl.java:147)
08/11/24 14:03:59 at com.qualcomm.qct.fadb.ui.bean.BaseHandler.createJobFolder(BaseHandler.java:1138)
08/11/24 14:03:59 at com.qualcomm.qct.fadb.ui.bean.RMAJobHandlerBean.saveJob(RMAJobHandlerBean.java:466)
08/11/24 14:03:59 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
08/11/24 14:03:59 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
08/11/24 14:03:59 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
08/11/24 14:03:59 at java.lang.reflect.Method.invoke(Method.java:585)
08/11/24 14:03:59 at com.sun.el.parser.AstValue.invoke(AstValue.java:151)
08/11/24 14:03:59 at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
08/11/24 14:03:59 at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)
08/11/24 14:03:59 at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:77)
08/11/24 14:03:59 at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:91)
08/11/24 14:03:59 at javax.faces.component.UICommand.broadcast(UICommand.java:383)
08/11/24 14:03:59 at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:317)
08/11/24 14:03:59 at org.ajax4jsf.component.AjaxViewRoot.broadcastEvents(AjaxViewRoot.java:292)
08/11/24 14:03:59 at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:249)
08/11/24 14:03:59 at org.ajax4jsf.component.AjaxViewRoot.processApplication(AjaxViewRoot.java:462)

[ November 24, 2008: Message edited by: Rajeev Ravindran ]
 
Rajeev Ravindran
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok nevermind Had to change lst.add("chmod"); to lst.add("/usr/bin/chmod"); to make it run from the app. i still need to work on my unix knowledge

Thanks,
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!