User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 402,391 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,896 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 4165 | Replies: 4
Join Date: Apr 2007
Posts: 108
Reputation: new_2_java is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 6
new_2_java new_2_java is offline Offline
Junior Poster

Executing Shell script from Java code.

  #1  
Jul 4th, 2007
Hi all,

I would like to execute a shell script from my java code. Can some one please tell me if that is possible? Here's what I tried, but with no result.

public class RunPDCC
{
        public static void main(String[] args)
        {
                try
                {
                        Process proc = Runtime.getRuntime().exec("./test.sh");
                        System.out.println("Print Test Line.");
                }
                catch (Exception e)
                {
                        System.out.println(e.getMessage());
                        e.printStackTrace();
                }
        }
}

In this program, I try to run the "./test.sh" shell script, which-for now-I have, just (echo "Hellow World"). But it doesn't seem that the script runs from within my code.

Can some one please tell me if I am in the right track, and how/if I am able to run the script from within my Java code....

Thanks and regards,
AddThis Social Bookmark Button
Reply With Quote  

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 1:19 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC