working on it ...


Explore Public Snippets

Sort by

Found 4,878 snippets matching: remote

    public by lbottaro  406565  1  7  9

    Simple CORBA java server

    This code shows an example of simple corba server in java. A CORBA server needs a local ORB object. The server instantiates an ORB and registers its servant objects so that the ORB can find the server when it receives an invocation for it. the server is a process that instantiates one or more servant objects. Each servant implements the
    // The package containing our stubs.
    import HelloApp.*;
    // HelloServer will use the naming service.
    import org.omg.CosNaming.*;
    // The package containing special exceptions thrown by the name service.
    import org.omg.CosNaming.NamingContextPackage.*;
    // All CORBA applications need these classes.
    import org.omg.CORBA.*;
    public class HelloServer 
      public static void main(String args[])
           // Create and initialize the ORB
          ORB orb = ORB.init(args, null);
          // Create the servant and register it with the ORB
          HelloServant helloRef = new HelloServant();
          // Get the root naming context
        org.omg.CORBA.Object objRef = 
          NamingContext ncRef = NamingContextHelper.narrow(objRef);
          // Bind the object reference in naming
          NameComponent nc = new NameComponent("Hello", "");
          NameComponent path[] = {nc};
          ncRef.rebind(path, helloRef);
          // Wait for invocations from clients
          java.lang.Object sync = new java.lang.Object();
              } catch(Exception e) {
            System.err.println("ERROR: " + e);
    class HelloServant extends _HelloImplBase
      public String sayHello()
        return "\nHello world!!\n";

    public by lbottaro  341378  3  7  1

    How to checkout the latest tag of a Git repository

    This simple bash script allows to automatically checkout your local git repository on the latest tagged version available on the remote repository. The script assumes to be run from your local repo. The command 'git rev-list --tags' lists the tags IDs in reverse chronological order, getting the very last one on top. The command 'git describe
    # Get new tags from the remote
    git fetch --tags
    # Get the latest tag name
    latestTag=$(git describe --tags `git rev-list --tags --max-count=1`)
    # Checkout the latest tag
    git checkout $latestTag  

    public by lbottaro  294405  1  6  3

    Simple RMI Java client

    This is a simple RMI client implementation. Here the client program obtains a stub for the registry on the server's host, then looks up the remote object's stub by name in the registry. Finally invokes the sayHello method on the remote object using the stub. Here the client invokes the method exposes by Hello remote interface. Note that if no
    package example.hello;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.registry.Registry;
    public class Client {
        private Client() {}
        public static void main(String[] args) {
    	String host = (args.length < 1) ? null : args[0];
    	try {
    	    Registry registry = LocateRegistry.getRegistry(host);
    	    Hello stub = (Hello) registry.lookup("Hello");
    	    String response = stub.sayHello();
    	    System.out.println("response: " + response);
    	} catch (Exception e) {
    	    System.err.println("Client exception: " + e.toString());

    public by libby  244806  1  5  0

    Add remote repo

    The remote is an external location for the repository, i.e. where it lives on git hub. Generally, a repository has one remote, but it is not limited to one remote.
    git remote add origin

    public by lbottaro  281550  2  6  3

    Simple RMI Java server

    This code shows a basic RMI server example. A "server" is the class which has a main method that creates an instance of the remote object implementation, exports the remote object and then binds that instance to a name in a RMI registry. Here the server implements the remote interface Hello. The class that contains this main method could be the
    package example.hello;
    import java.rmi.registry.Registry;
    import java.rmi.registry.LocateRegistry;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    public class Server implements Hello {
        public Server() {}
        public String sayHello() {
    	return "Hello, world!";
        public static void main(String args[]) {
    	try {
    	    Server obj = new Server();
    	    Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);
    	    // Bind the remote object's stub in the registry
    	    Registry registry = LocateRegistry.getRegistry();
    	    registry.bind("Hello", stub);
    	    System.err.println("Server ready");
    	} catch (Exception e) {
    	    System.err.println("Server exception: " + e.toString());

    public by lbottaro  170296  0  6  0

    Simple RMI Java interface

    A simple RMI interface example. A remote interface extends the interface java.rmi.Remote and declares a set of remote methods. Each remote method must declare java.rmi.RemoteException (or a superclass of RemoteException) in its throws clause, in addition to any application-specific exceptions. This interface declares just one method, sayHello, w
    package example.hello;
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface Hello extends Remote {
        String sayHello() throws RemoteException;

    public by lbottaro  6112  5  8  1

    How to check if a Git remote repository is available in python

    This simple python code shows how to check if a given Git remote repository is available. The code invokes the git command 'git ls-remote' on the remote URL path as subprocess with Popen and checks the exit code, using the communicate() method. The command exit status is stored into the 'returncode' property. A value not-equals to '0' mean
    from subprocess import Popen, PIPE, STDOUT
    p = Popen(["git", "ls-remote", "git://remote_path"], stdout=PIPE)
    output = p.communicate()[0]
    if p.returncode != 0:
      print "Command failed ["+str(p.returncode)+"]"        

    public by lbottaro  3619  3  6  3

    How to invoke the EJB remote interface - Java client application

    The codes shows how to remotely invoke the methods exposed by EJB remote interface. The client app will invoke the remote methods using a JNDI lookup. The appName and beanName refer to the remote application and ejb names to be referenced by the client app. Notice the usage of InitialContext, setting variables INITIAL_CONTEXT_FACTORY and PROVIDE
    package com.test.ejbclient;
    import java.util.List;
    import java.util.Properties;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import com.test.example.interfaces.IPerson;
    import com.test.example.person.*;
    public class Ejbclient {
    	public static void main(String[] args) {
    		// TODO Auto-generated method stub
    		IPerson person = doLookup();
    		Person p = person.getPerson(4);
    		List<Person> pList = person.getPersonList();
    		for (Person person2 : pList) {
    	private static IPerson doLookup() {
    		IPerson bean = null;
    		try {
    			bean = lookupRemoteStatelessPersonEJB();
    		} catch (NamingException e) {
    			// TODO Auto-generated catch block
    		return bean;
    	private static String getLookupName() {
    		//The app name
            final String appName = "PersonWebAppEJB_Final";
            // The EJB name which by default is the simple class name of the bean implementation class
            final String beanName = "PersonEJB";
            // the remote view fully qualified class name
            final String viewClassName = IPerson.class.getName();
            // let's do the lookup
            String url = appName + "/" +beanName + "!" + viewClassName;
            System.out.println("URL: " + url);
    		return url;
    	private static IPerson lookupRemoteStatelessPersonEJB() throws NamingException {
    		Properties env = new Properties(); 
    		env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");
    		env.put(Context.PROVIDER_URL, "remote://");
    		String userName = "user";
    		String password = "password";
    		env.put(Context.SECURITY_PRINCIPAL, userName);
    		env.put(Context.SECURITY_CREDENTIALS, password);
    		env.put("jboss.naming.client.ejb.context", true);
    		InitialContext context = new InitialContext(env); 
            // let's do the lookup
            String url = getLookupName();
            return (IPerson) context.lookup(url);

    public by lbottaro  5357  7  7  1

    smbclient to remotely copy from linux to windows env

    This script allows to keep synchronized a windows based client with a linux machine. Details for smbclient command: -U: set the credentials to login -c: execute a command (between quotes) The command executed includes: -lcd: set the specified directory to local machine -mput: copy one or more local files to the remote computer
    # Linux source directory to copy from: /home/tmp/
    # Windows target directory where to copy: \\\SharedDirectory\filesDir
    echo '- Updating Client folder -'
    smbclient -U $user%$pwd //$targetIP/$sharedDirRoot -c "cd $targetDir; lcd $linuxSourceDir; prompt off;recurse; mput *;"
    echo '- Remote Client Updated -'

    public by lbottaro  3349  4  7  0

    Remote execution of command on clearcase view via ssh

    This bash script allows to execute a dynamic command on a remote machine, using ssh authentication within a Clearcase dynamic view. Note that the command to run in generated by some variables and it's passed to ssh via a file. The cat command will input the command into remote shell to be executed on another machine. You can find also th
    # This return current directory
    # This return the CLearcase view name
    currentView=`cleartool pwv -s`
    echo "Setting view: ${currentView} on remote machine"
    # This is the command to execute
    cmd="cleartool setview -exec \"echo currentDir=${currentDir}; echo my_dest_path=${my_dest_path}; cd ${currentDir}; cp -an data/* ${my_dest_path}; hostname\" ${currentView}"
    echo "cmd=${cmd}"
    # This is a tmp file where to save the command
    rm -f ${file}
    # Create a tmp file to save the command to execute
    echo ${cmd} > ${file}
    # This run the command on <remoteMachine>
    /usr/bin/time -f "%E" -o ${my_platform_label}.time ssh -Y <remoteMachine> 'bash -s' < ${file}
    • Public Snippets
    • Channels Snippets