You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by Russell E Glaue <rg...@cait.org> on 2005/09/21 17:16:53 UTC

Re: Give James' telnet:4555 service a prompt

 > What do you mean by prompt?  Just the first message that is sent when
 > you connect?  How configurable would you expect this to be?

Well, I mean something like a shell prompt.
When you telnet to port 4555, you get no prompt.
If you telnet to Linux which bash shell, you might get the '-bash-3.00% ' prompt 
(for example).

When using the Perl Net::Telnet module, it wants and expects a prompt to be 
defined so it knows when it can send the next list of characters for a command.

So for example, if I could configure the prompt to be 'james> ', then this can 
happen in my terminal:


-bash-3.00$ telnet localhost 4555
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
JAMES Remote Administration Tool 2.2.0
Please enter your login and password
Login id:
root
Password:
********
Welcome root. HELP for a list of commands
james> listusers
Existing accounts 1
user: jamesadmin
james> quit
Bye
Connection closed by foreign host.
-bash-3.00$

* Note, the appearance of 'james> ' is a prompt I would like to have defined. 
Currently you are given nothing to prompt you that you can start entering a command.

And then I could make a little PERL script to shutdown JAMES like this:

-bash-3.00$ cat james-shutdown.pl
##!/bin/bash
use Net::Telnet;
use strict;
my $telnet = new Net::Telnet (
                         Host    => "localhost",
                         Port    => "4555",
                         Prompt  => "/^james>/");
$telnet->open();
$telnet->waitfor(/Login id:\s*\n/);
$telnet->print("root");
$telnet->waitfor(/Password:\s*\n/);
$telnet->print("********");
$telnet->cmd("shutdown");
print $telnet->getlines();
$telnet->close();
__END__
-bash-3.00$


So you can see one importance of having a defined prompt for the administrative 
shell on telnet:4555 JAMES admin service.
If we admins want to execute automated tasks, like shutdown, add user, from 
other programs/scripts, we need a prompt to appear to tell the script when it 
can input information.


So I ask again. Can a shell prompt for the JAMES admin service on port 4555 be 
defined? How can I do this?
Actually, I do not really care too much what the prompt is. I just want a prompt.

-RG



Serge Knystautas wrote:
> On 8/17/05, Russell E Glaue <rg...@cait.org> wrote:
> 
>>Who can tell me (without having to change the source code) how to define
>>a prompt the telnet service JAMES has on port 4555 for administration?
>>Is it possible to set the prompt? Configure a prompt somewhere?
>>If not, can this be added into a future release of JAMES so that
>>administrators can define a prompt if they like?
>>Anyone have any philosophy on this matter?
> 
> 
> What do you mean by prompt?  Just the first message that is sent when
> you connect?  How configurable would you expect this to be?
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Give James' telnet:4555 service a prompt

Posted by Stefano Bagnara <ap...@bago.org>.
> That is really Great!
> Any idea what next release of JAMES will contain this change?
> -RG

Probably the next one, but I don't know WHEN.

Stefano


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Give James' telnet:4555 service a prompt

Posted by Russell E Glaue <rg...@cait.org>.
That is really Great!
Any idea what next release of JAMES will contain this change?
-RG


AVee wrote:
> On Thursday 22 September 2005 15:59, Danny Angus wrote:
> 
>>If you want to have a go at making the change yourself look at this file:
>>
>>http://svn.apache.org/viewcvs.cgi/james/server/trunk/src/java/org/apache/ja
>>mes/remotemanager/RemoteManagerHandler.java?view=markup
>>
>>and this block:
>>
>> while (parseCommand(in.readLine())) {
>>      theWatchdog.reset();
>>}
>>
>>I think you need to output the prompt once before the while, and in the
>>loop.
> 
> 
> Wich is just what I've been writing last week :)
> A patch against the trunk is attached, this adds an optional <prompt> element 
> to the remote manager handler block, like this: 
>    <remotemanager>
>       <port>4555</port>
>       <handler>
>          <helloName autodetect="true">myMailServer</helloName>
>          <administrator_accounts>
>             <account login="root" password="root"/>
>          </administrator_accounts>
>          <connectiontimeout> 60000 </connectiontimeout>
> 	 <prompt>james&gt;</prompt>
>       </handler>
>    </remotemanager>
> 
> The prompt element is optional, when left out the prompt is set to an empty 
> string, so when the configuration is unchanged the behaviour also is 
> unchanged.
> 
> Arjan.
> 
> 
> ------------------------------------------------------------------------
> 
> Index: /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java
> ===================================================================
> --- /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java	(revision 290830)
> +++ /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManager.java	(working copy)
> @@ -66,6 +66,11 @@
>      private UsersRepository users;
>  
>      /**
> +     * The service prompt to be displayed when waiting for input.
> +     */
> +    private String prompt = "";
> +    
> +    /**
>       * The reference to the internal MailServer service
>       */
>      private MailServer mailServer;
> @@ -122,6 +127,10 @@
>                  adminAccounts.put( accounts[ i ].getAttribute( "login" ),
>                                     accounts[ i ].getAttribute( "password" ) );
>              }
> +            Configuration promtConfiguration = handlerConfiguration.getChild("prompt", false);
> +            if (promtConfiguration != null) prompt = promtConfiguration.getValue();
> +            if (prompt == null) prompt = ""; 
> +            else if (!prompt.equals("") && !prompt.endsWith(" ")) prompt += " "; 
>          }
>      }
>  
> @@ -261,5 +270,12 @@
>              return RemoteManager.this.adminAccounts;
>          }
>  
> +        /**
> +         * @see org.apache.james.remotemanager.RemoteManagerHandlerConfigurationData#getPrompt()
> +         */
> +        public String getPrompt() {
> +            return RemoteManager.this.prompt;
> +        }
> +
>      }
>  }
> Index: /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java
> ===================================================================
> --- /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java	(revision 290830)
> +++ /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java	(working copy)
> @@ -298,9 +298,13 @@
>              }
>  
>              try {
> +                out.print(theConfigData.getPrompt());
> +                out.flush();
>                  theWatchdog.start();
>                  while (parseCommand(in.readLine())) {
>                      theWatchdog.reset();
> +                    out.print(theConfigData.getPrompt());
> +                    out.flush();
>                  }
>                  theWatchdog.stop();
>              } catch (IOException ioe) {
> Index: /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java
> ===================================================================
> --- /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java	(revision 290830)
> +++ /home/avee/eclipse/workspace/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandlerConfigurationData.java	(working copy)
> @@ -67,4 +67,11 @@
>       */
>      HashMap getAdministrativeAccountData();
>  
> +    /**
> +     * Returns the prompt to be displayed when waiting for input. e.g. "james> ".
> +     * 
> +     * @return the configured prompt, or an empty string when the prompt is not configured.
> +     */
> +    String getPrompt();
> +
>  }
> 
> 
> 
> ------------------------------------------------------------------------
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Give James' telnet:4555 service a prompt

Posted by AVee <av...@avee.org>.
On Wednesday 28 September 2005 16:57, Stefano Bagnara wrote:
> Hi Avee,
>
> Can you file this to JIRA, add the patch as attachment and give the
> consensus for inclusion in ASL code?

Done
http://issues.apache.org/jira/browse/JAMES-423
>
> Thank you,
> Stefano
>
> > -----Messaggio originale-----
> > Da: AVee [mailto:avee@avee.org]
> > Inviato: giovedì 22 settembre 2005 17.25
> > A: James Users List
> > Oggetto: Re: Give James' telnet:4555 service a prompt
> >
> > On Thursday 22 September 2005 15:59, Danny Angus wrote:
> > > If you want to have a go at making the change yourself look
> >
> > at this file:
> > >http://svn.apache.org/viewcvs.cgi/james/server/trunk/src/java
> >
> > /org/apach
> >
> > >e/ja mes/remotemanager/RemoteManagerHandler.java?view=markup
> > >
> > > and this block:
> > >
> > >  while (parseCommand(in.readLine())) {
> > >       theWatchdog.reset();
> > > }
> > >
> > > I think you need to output the prompt once before the while, and in
> > > the loop.
> >
> > Wich is just what I've been writing last week :) A patch
> > against the trunk is attached, this adds an optional <prompt>
> > element to the remote manager handler block, like this:
> >    <remotemanager>
> >       <port>4555</port>
> >       <handler>
> >          <helloName autodetect="true">myMailServer</helloName>
> >          <administrator_accounts>
> >             <account login="root" password="root"/>
> >          </administrator_accounts>
> >          <connectiontimeout> 60000 </connectiontimeout>
> > 	 <prompt>james&gt;</prompt>
> >       </handler>
> >    </remotemanager>
> >
> > The prompt element is optional, when left out the prompt is
> > set to an empty string, so when the configuration is
> > unchanged the behaviour also is unchanged.
> >
> > Arjan.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
> For additional commands, e-mail: server-user-help@james.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Give James' telnet:4555 service a prompt

Posted by Stefano Bagnara <ap...@bago.org>.
Hi Avee,

Can you file this to JIRA, add the patch as attachment and give the
consensus for inclusion in ASL code?

Thank you,
Stefano

> -----Messaggio originale-----
> Da: AVee [mailto:avee@avee.org] 
> Inviato: giovedì 22 settembre 2005 17.25
> A: James Users List
> Oggetto: Re: Give James' telnet:4555 service a prompt
> 
> On Thursday 22 September 2005 15:59, Danny Angus wrote:
> >
> > If you want to have a go at making the change yourself look 
> at this file:
> >
> > 
> >http://svn.apache.org/viewcvs.cgi/james/server/trunk/src/java
> /org/apach
> >e/ja mes/remotemanager/RemoteManagerHandler.java?view=markup
> >
> > and this block:
> >
> >  while (parseCommand(in.readLine())) {
> >       theWatchdog.reset();
> > }
> >
> > I think you need to output the prompt once before the while, and in 
> > the loop.
> 
> Wich is just what I've been writing last week :) A patch 
> against the trunk is attached, this adds an optional <prompt> 
> element to the remote manager handler block, like this: 
>    <remotemanager>
>       <port>4555</port>
>       <handler>
>          <helloName autodetect="true">myMailServer</helloName>
>          <administrator_accounts>
>             <account login="root" password="root"/>
>          </administrator_accounts>
>          <connectiontimeout> 60000 </connectiontimeout>
> 	 <prompt>james&gt;</prompt>
>       </handler>
>    </remotemanager>
> 
> The prompt element is optional, when left out the prompt is 
> set to an empty string, so when the configuration is 
> unchanged the behaviour also is unchanged.
> 
> Arjan.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org


Re: Give James' telnet:4555 service a prompt

Posted by AVee <av...@avee.org>.
On Thursday 22 September 2005 15:59, Danny Angus wrote:
>
> If you want to have a go at making the change yourself look at this file:
>
> http://svn.apache.org/viewcvs.cgi/james/server/trunk/src/java/org/apache/ja
>mes/remotemanager/RemoteManagerHandler.java?view=markup
>
> and this block:
>
>  while (parseCommand(in.readLine())) {
>       theWatchdog.reset();
> }
>
> I think you need to output the prompt once before the while, and in the
> loop.

Wich is just what I've been writing last week :)
A patch against the trunk is attached, this adds an optional <prompt> element 
to the remote manager handler block, like this: 
   <remotemanager>
      <port>4555</port>
      <handler>
         <helloName autodetect="true">myMailServer</helloName>
         <administrator_accounts>
            <account login="root" password="root"/>
         </administrator_accounts>
         <connectiontimeout> 60000 </connectiontimeout>
	 <prompt>james&gt;</prompt>
      </handler>
   </remotemanager>

The prompt element is optional, when left out the prompt is set to an empty 
string, so when the configuration is unchanged the behaviour also is 
unchanged.

Arjan.

Re: Give James' telnet:4555 service a prompt

Posted by Danny Angus <Da...@slc.co.uk>.
You don't need to use the admin tool to shutdown james, there are
start/stop scripts which can be used to automate james.

Having a prompt to allow scripts to perform admin tasks sounds like a
reasonable request though.

If you want to have a go at making the change yourself look at this file:

http://svn.apache.org/viewcvs.cgi/james/server/trunk/src/java/org/apache/james/remotemanager/RemoteManagerHandler.java?view=markup

and this block:

 while (parseCommand(in.readLine())) {
      theWatchdog.reset();
}

I think you need to output the prompt once before the while, and in the
loop.

d.







|---------+---------------------------->
|         |           Russell E Glaue  |
|         |           <rg...@cait.org>|
|         |                            |
|         |           21/09/2005 16:16 |
|         |           Please respond to|
|         |           "James Users     |
|         |           List"            |
|---------+---------------------------->
  >-------------------------------------------------------------------------------------------------------------------------------|
  |                                                                                                                               |
  |       To:       James Users List <se...@james.apache.org>                                                               |
  |       cc:                                                                                                                     |
  |       Subject:  Re: Give James' telnet:4555 service a prompt                                                                  |
  >-------------------------------------------------------------------------------------------------------------------------------|




 > What do you mean by prompt?  Just the first message that is sent when
 > you connect?  How configurable would you expect this to be?

Well, I mean something like a shell prompt.
When you telnet to port 4555, you get no prompt.
If you telnet to Linux which bash shell, you might get the '-bash-3.00% '
prompt
(for example).

When using the Perl Net::Telnet module, it wants and expects a prompt to be

defined so it knows when it can send the next list of characters for a
command.

So for example, if I could configure the prompt to be 'james> ', then this
can
happen in my terminal:


-bash-3.00$ telnet localhost 4555
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
JAMES Remote Administration Tool 2.2.0
Please enter your login and password
Login id:
root
Password:
********
Welcome root. HELP for a list of commands
james> listusers
Existing accounts 1
user: jamesadmin
james> quit
Bye
Connection closed by foreign host.
-bash-3.00$

* Note, the appearance of 'james> ' is a prompt I would like to have
defined.
Currently you are given nothing to prompt you that you can start entering a
command.

And then I could make a little PERL script to shutdown JAMES like this:

-bash-3.00$ cat james-shutdown.pl
##!/bin/bash
use Net::Telnet;
use strict;
my $telnet = new Net::Telnet (
                         Host    => "localhost",
                         Port    => "4555",
                         Prompt  => "/^james>/");
$telnet->open();
$telnet->waitfor(/Login id:\s*\n/);
$telnet->print("root");
$telnet->waitfor(/Password:\s*\n/);
$telnet->print("********");
$telnet->cmd("shutdown");
print $telnet->getlines();
$telnet->close();
__END__
-bash-3.00$


So you can see one importance of having a defined prompt for the
administrative
shell on telnet:4555 JAMES admin service.
If we admins want to execute automated tasks, like shutdown, add user, from

other programs/scripts, we need a prompt to appear to tell the script when
it
can input information.


So I ask again. Can a shell prompt for the JAMES admin service on port 4555
be
defined? How can I do this?
Actually, I do not really care too much what the prompt is. I just want a
prompt.

-RG



Serge Knystautas wrote:
> On 8/17/05, Russell E Glaue <rg...@cait.org> wrote:
>
>>Who can tell me (without having to change the source code) how to define
>>a prompt the telnet service JAMES has on port 4555 for administration?
>>Is it possible to set the prompt? Configure a prompt somewhere?
>>If not, can this be added into a future release of JAMES so that
>>administrators can define a prompt if they like?
>>Anyone have any philosophy on this matter?
>
>
> What do you mean by prompt?  Just the first message that is sent when
> you connect?  How configurable would you expect this to be?
>


---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org




***************************************************************************
The information in this e-mail is confidential and for use by the addressee(s) only. If you are not the intended recipient (or responsible for delivery of the message to the intended recipient) please notify us immediately on 0141 306 2050 and delete the message from your computer. You may not copy or forward it or use or disclose its contents to any other person. As Internet communications are capable of data corruption Student Loans Company Limited does not accept any  responsibility for changes made to this message after it was sent. For this reason it may be inappropriate to rely on advice or opinions contained in an e-mail without obtaining written confirmation of it. Neither Student Loans Company Limited or the sender accepts any liability or responsibility for viruses as it is your responsibility to scan attachments (if any). Opinions and views expressed in this e-mail are those of the sender and may not reflect the opinions and views of The Student Loans Company Limit
 ed.

This footnote also confirms that this email message has been swept for the presence of computer viruses.

**************************************************************************

---------------------------------------------------------------------
To unsubscribe, e-mail: server-user-unsubscribe@james.apache.org
For additional commands, e-mail: server-user-help@james.apache.org