Two Laptop Bag*
The moose likes Java in General and the fly likes call shell script and create a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "call shell script and create a file" Watch "call shell script and create a file" New topic

call shell script and create a file

Vijay Raj
Ranch Hand

Joined: Oct 10, 2005
Posts: 110

I need to call a shell script from my Java code. That works. But I am not able to create a file using 'touch' (in Linux). The shell script has the touch command and its not creating a new file.

I used policytool to set teh policy to AllPermissions, even tried to set teh permission to FilePermission but nothing worked.

What could be the problem.

Lanny Gilbert
Ranch Hand

Joined: Jun 11, 2002
Posts: 103
You say that the shell script contains the "touch". If you run the shell script in standalone mode (i.e. from command line, not from your program), does the "touch" work? Maybe the user you are running the Java program as doesn't have permission to create a file in the directory. there are several possibilities here, but first let us know if the script works by itself.
Paul Clapham

Joined: Oct 14, 2005
Posts: 18541

So instead of calling a shell script to create a file, why not something simple like
I agree. Here's the link:
subject: call shell script and create a file
Similar Threads
Ant exec task -- unable to execute a command
Get the UNIX process ID of the java program
Tomcat installation on Linux.. Please help..
porting a .bat file to unix
How to call Java program main method from shell script