?
Solved

Change directory and permissions

Posted on 2003-03-14
6
Medium Priority
?
314 Views
Last Modified: 2012-08-14
Hi all,

I need to change directories and edit permissions on a file using java.
I know you have to use the runtime environment but i was just wondering how i would do that.


i need to change directories to /usr/iplanet/servers/docs/scripts
then i need to change permissions on file run.sh to make it executable

Some example code would be helpful

thanx

Tom
0
Comment
Question by:tommyboy2214
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 35

Expert Comment

by:girionis
ID: 8136737
 You can use:

  Runtime.getRuntime().exec("chmod -777 /usr/iplanet/server/docs/scripts");

0
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 8136744
 sorry...

 Runtime.getRuntime().exec("chmod -777 /usr/iplanet/server/docs/scripts/run.sh");
0
 

Author Comment

by:tommyboy2214
ID: 8136925
thanx alot


0
Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

 
LVL 35

Expert Comment

by:girionis
ID: 8137078
 Thank you :-) I am glad I helped. Bare in mind though that this will only work under Unix/Linux and not under Windows.
0
 
LVL 1

Expert Comment

by:sct75
ID: 8137367
When you take runtime as your solution, you may sacrifice Java's portability by tying your solution specifically to the underline OS structure, for example, UNIX or Windows.

Following is what you need to do.

String userDirectory = "/usr/iplanet/servers/docs/scripts";
String[] command = new String[3];
command[0] = "chmod";
command[1] = "744";
command[2] = userDirectory + "/run.sh";

Runtime.getRuntime().exec(command);
0
 
LVL 35

Expert Comment

by:girionis
ID: 8137442
 Or you can even pass the information through a properties file and load it up using ResourceBundle. Particular useful because you a) maintain java portability and b) you can load thsi info from any class and you do not have to pass it through the command prompt.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question