def do_exec(self, args):
     """ Execute a shell command on the remote host and get back the output
 
     usage:
     
       exec <cmd> [<arguments>]
 """
     client = SystemAdministratorClient(self.host, self.port)
     result = client.executeCommand(args)
     if not result['OK']:
         self.__errMsg(result['Message'])
     status, output, error = result['Value']
     print
     for line in output.split('\n'):
         print line
     if error:
         self.__errMsg(status)
         for line in error.split('\n'):
             print line
Пример #2
0
  def do_exec( self, args ):
    """ Execute a shell command on the remote host and get back the output

        usage:

          exec <cmd> [<arguments>]
    """
    client = SystemAdministratorClient( self.host, self.port )
    result = client.executeCommand( args )
    if not result['OK']:
      self.__errMsg( result['Message'] )
    status, output, error = result['Value']
    print
    for line in output.split( '\n' ):
      print line
    if error:
      self.__errMsg( status )
      for line in error.split( '\n' ):
        print line
    def do_cd(self, args):
        """ Change the current working directory on the target host
    
        Usage:
          cd <dirpath>
    """
        argss = args.split()

        if len(argss) == 0:
            # Return to $HOME
            if self.homeDir:
                self.previous_cwd = self.cwd
                self.cwd = self.homeDir
            else:
                client = SystemAdministratorClient(self.host, self.port)
                command = 'echo $HOME'
                result = client.executeCommand(command)
                if not result['OK']:
                    self.__errMsg(result['Message'])
                    return
                status, output, _error = result['Value']
                if not status and output:
                    self.homeDir = output.strip()
                    self.previous_cwd = self.cwd
                    self.cwd = self.homeDir
            self.prompt = '[%s:%s]> ' % (self.host, self.cwd)
            return

        newPath = argss[0]
        if newPath == '-':
            if self.previous_cwd:
                cwd = self.cwd
                self.cwd = self.previous_cwd
                self.previous_cwd = cwd
        elif newPath.startswith('/'):
            self.previous_cwd = self.cwd
            self.cwd = newPath
        else:
            newPath = self.cwd + '/' + newPath
            self.previous_cwd = self.cwd
            self.cwd = os.path.normpath(newPath)
        self.prompt = '[%s:%s]> ' % (self.host, self.cwd)
Пример #4
0
 def do_cd( self, args ):    
   """ Change the current working directory on the target host
   
       Usage:
         cd <dirpath>
   """
   argss = args.split()
   
   if len( argss ) == 0:
     # Return to $HOME
     if self.homeDir:
       self.previous_cwd = self.cwd
       self.cwd = self.homeDir
     else:  
       client = SystemAdministratorClient( self.host, self.port )
       command = 'echo $HOME'
       result = client.executeCommand( command )
       if not result['OK']:
         self.__errMsg( result['Message'] )
         return
       status, output, _error = result['Value']
       if not status and output:
         self.homeDir = output.strip()
         self.previous_cwd = self.cwd
         self.cwd = self.homeDir
     self.prompt = '[%s:%s]> ' % ( self.host, self.cwd )  
     return
       
   newPath = argss[0]
   if newPath == '-':
     if self.previous_cwd:
       cwd = self.cwd
       self.cwd = self.previous_cwd
       self.previous_cwd = cwd
   elif newPath.startswith( '/' ):
     self.previous_cwd = self.cwd
     self.cwd = newPath
   else:
     newPath = self.cwd + '/' + newPath
     self.previous_cwd = self.cwd
     self.cwd = os.path.normpath( newPath )  
   self.prompt = '[%s:%s]> ' % ( self.host, self.cwd )  
Пример #5
0
  def do_exec( self, args ):
    """ Execute a shell command on the remote host and get back the output

        usage:

          exec <cmd> [<arguments>]
    """
    client = SystemAdministratorClient( self.host, self.port )
    command = 'cd %s;' % self.cwd + args
    result = client.executeCommand( command )
    if not result['OK']:
      self.__errMsg( result['Message'] )
      return
    status, output, error = result['Value']
    gLogger.notice( '' )
    for line in output.split( '\n' ):
      gLogger.notice( line )
    if error:
      self.__errMsg( status )
      for line in error.split( '\n' ):
        gLogger.notice( line )
Пример #6
0
  def do_exec( self, args ):
    """ Execute a shell command on the remote host and get back the output

        usage:

          exec <cmd> [<arguments>]
    """
    client = SystemAdministratorClient( self.host, self.port )
    command = 'cd %s;' % self.cwd + args
    result = client.executeCommand( command )
    if not result['OK']:
      self.__errMsg( result['Message'] )
      return
    status, output, error = result['Value']
    gLogger.notice( '' )
    for line in output.split( '\n' ):
      gLogger.notice( line )
    if error:
      self.__errMsg( status )
      for line in error.split( '\n' ):
        gLogger.notice( line )