only search Wiseman.La

The World NEXT ends 


This is probably trivially obvious, but I use this code not infrequently, so why not post it....

Mr. Demicoli has posted an idea on ideajam to be able to right-click on an agent and "run on server". It's a good idea - go vote for it.

Until then, if you want to run an agent on the server, you can send a console command with the easy to remember syntax "Tell amgr run "apps\NA\LA\myDB.nsf" 'myagent'" (make sure you get those quotes right, btw), or you can add an agent that has the following code:

%REM

     Agent CPW\Run myAgent on the server
     Created Sep 17, 2007 by Craig Wiseman/CPW
     Description: This code runs the denoted agent on the server.
%END REM

Option
Public
Option
Declare

Sub
Initialize()
  Dim session As New NotesSession
  Dim
db As NotesDatabase
  Dim
agent As NotesAgent

   Set
db = session.CurrentDatabase

  If
db.server = "" Then
       Print "Not on server!"
  Else

       Set agent = db.GetAgent( "myAgent's Name" )
       Call agent.runonserver        
  End
If

End
Sub

Comments (4)
Craig Wiseman March 29th, 2010 01:43:53 PM

 Comments
1) While we wait for Mr. Demicoli’s idea to be implemented by IBM: Running an agent on the server
David Leedy http://notesin9.com 3/29/2010 3:15:45 PM

You do need to be careful with the console command. If I recall correctly launching an agent that way runs in a thread DIFFERENT then the agent manager. That means that you can't really kill it. Also - it does NOT respect agent run time limiters. So if it's set for 45 minutes on your server - you kick it off from the console and it might just keep going.

I'm more a dev then admin but that's been my experience with it. So you need to be a little careful with that one.

2) While we wait for Mr. Demicoli’s idea to be implemented by IBM: Running an agent on the server
Kevin Pettitt http://www.lotusguru.com 3/29/2010 3:18:31 PM

I use the agent calling an agent approach a fair bit. It is great because you can restrict the running of the user-called agent to a specific ACL role, which means you could even put the agent in the action menu and it won't be visible to unauthorized users. You could have folks with only reader access issue console commands, change agent settings and re-sign agents in the current database...all sorts of dangerous, I mean fun, stuff. :-)

3) While we wait for Mr. Demicoli’s idea to be implemented by IBM: Running an agent on the server
Craig Wiseman http://www.Wiseman.La/cpw 3/29/2010 3:33:54 PM

@1 You're correct - it runs in it's own unkillable thread. But you'd NEVER be debugging an agent on your |production| server, right?

@2 Indeed. Many, many, fun things you can do with this.

4) While we wait for Mr. Demicoli’s idea to be implemented by IBM: Running an agent on the server
Mark Demicoli http://www.ClickBook.net 3/29/2010 4:44:23 PM

This workaround uses AMGR directly from the console:

Tell Amgr run "database.nsf" 'agentNameOrAlias'

Ofcourse, you must have rights to punch away at the console :)


Discussion for this entry is now closed.