Shell

Introduction

Command-line and shell commands provide a way to execute code directly on the Windchill server. New shell commands can be added by defining a feature using the @WexComponent annotation:

@WexComponent(uid = "admin", description = "Wex example shell commands")
public class WexExampleShell {

    @WexShellMethod(alias = "ec", description = "Example Command")
    public void list() throws Exception {
        System.out.println("Shell result");
    }
}

Commands

Because the Windchill shell runs in an isolated environment, it cannot access extension classes directly. To expose functionality as a shell command, define a command-line feature as follows:

import com.wincomplm.wex.kernel.impl.annotations.WexComponent;
import com.wincomplm.wex.kernel.impl.wki.IWexCommandLine;
import java.io.Serializable;
import wt.method.RemoteAccess;

@WexComponent(uid = "wex-example-testcmd", 
              description = "A exammple command line")
public class ExampleCommand implements Serializable, RemoteAccess, IWexCommandLine {

    public int execute(String[] args) {
        try {
            // Code here
        } catch (Exception e) {
            return 0;
        }
        return 1;
    }
}

The command is executed using the following kernel command:

windchill com.wincomplm.wex.kernel.commands.WexCommandLineExecutor -pid <wexid> -cid <cmdid>

For example:

windchill com.wincomplm.wex.kernel.commands.WexCommandLineExecutor -pid com.wincomplm.wex-example-command -cid wex-example-testcmd