JagManager command line switches (this howto is deprecated)Tag(s): DEPRECATED


java JaguarManager
   -U<username>
   -P<password>
   -S<server>
   -C<stop|restart|refresh>

import com.sybase.jaguar.system.*;
import org.omg.CORBA.*;
import java.util.Properties;
import SessionManager.*;

public class JaguarManager
{
    // written by Dave Wolf.
    private String url = "jdbc:sybase:Tds:localhost:7878";
    private String username = "jagadmin";
    private String password = "";
    private String command = "";


    public void parse(String[] args) {
        int len = args.length;
        for(int i = 0; i < len; i++) {
            String name = args[i];
            String value;
            int next = i+1;
            if(next >= len)
                value = "";
            else if(args[next].startsWith("-"))
                value = "";
            else {
                value = args[next];
                i++;
            }

            switch(name.charAt(1)) {
                case 'P':
                    password = value;
                    System.out.println(name + "=" + value);
                    break;
                case 'U':
                    username = value;
                    System.out.println(name + "=" + value);
                    break;
                case 'S':
                    url = value;
                    System.out.println(name+ "=" + value);
                    break;
                case 'C':
                    command = value;
                    System.out.println(name+ "=" + value);
                    break;
                default:
                    System.out.println("Unknown switch " + name);
            }
        }
    }

    public void process(){
        try {
            Properties props = new Properties();
            props.put("org.omg.CORBA.ORBClass","com.sybase.CORBA.ORB");
            ORB orb = ORB.init((String[]) null, props);
            Manager manager = ManagerHelper.narrow
               (orb.string_to_object(url));
            Session session = manager.createSession
               (username,password);
            Management server = ManagementHelper.narrow(session.create
               ("Jaguar/Management"));
            try{
                if(command.equals("stop")) {
                    server.shutdown();
                }
                if(command.equals("restart")) {
                    server.restart();
                }
            }
            catch(COMM_FAILURE ce)  {
                System.out.println("Process Complete!");
            }
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }

    public static void main(String[] args)
    {
        JaguarManager manager = new JaguarManager();
        manager.parse(args);
        manager.process();
    }
}
Since EAServer 3.6, the command line jagtool can be used for this purpose.

To stop/restart a server remotely, an easy way is create a small vbscript. Then we stop the Jaguar service using the WMI package.

var lSWbemServices = getWMISWbemServices("HostComputerName");
var lService = lSWbemServices.Get("Win32_Service='Jaguar'");
lService.StopService();
to start the service
lService.StartService();
See this How-To
blog comments powered by Disqus