This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

grant write access to folder in unix  RSS feed

 
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
 
Sheriff
Posts: 21550
100
Chrome Eclipse IDE Java Spring Ubuntu VI Editor 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,
 
Our first order of business must be this tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!