Hi,

I have this simple fab script and I want to execute from a java program.

 from __future__ import with_statement
    from fabric.api import *
    from fabric.contrib.console import confirm
    env.hosts = ['localhost']

    def updatefile():
     with shell_env(TERM='vt100'):
    with cd('/Users/'):
    run("pwd")
    run("ls -l")

    def execute():
      updatefile()


When I execute this script from command line it works : fab -f test.py
executes but I want to execute via java. Tried with ..

public class ExecuteScript {
@Testpublic void testExecuteScript() throws NumberFormatException, IOException{

    StringBuffer output = new StringBuffer();
    Process p;
    try {
        p = Runtime.getRuntime().exec("fab -f
src/test/resources/scripts/test.py execute");
        p.waitFor();
        BufferedReader reader =
                new BufferedReader(new InputStreamReader(p.getInputStream()));

        String line = "";
        while ((line = reader.readLine())!= null) {
            output.append(line + "\n");
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println(output.toString());}}

It doesn't work.. looked at the documentation for java examples
inhttp://fabric8.io/gitbook/quickstarts.html the links are broken.


Thanks,

Tameem
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user

Reply via email to