cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting components of Web AS

Former Member
0 Kudos

I want to script certain things in Visual Administrator, ConfigTool and start and stop the engine through script.

The things I like to control are things like adding a JDBC connection to the JDBC Connector (in VAdmin), adding a Java parameter to the server (in CTool) and others.

Is there a way to do this?

Can anyone point out a document or expert on this?

Thanks a lot,

Nir Arazi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Iavor.

Thanks for the useful information you gave me.

Just before I grant you with the points you deserve, please answer some questions...

First of all, I cannot run the ADD DBPOOL command on my server. It gives me this response: "There aren't commands from DBPOOL group in the CommandContext". What should I do to get this running?

Second, you said I can write a script and put it in the server folder. Which folder is that?? C:\usr\sap\J2E\JC00\j2ee\cluster\server0 ?? a folder inside this ??

And how should I run this? from the root dir in telnet? should I browse to a different location?

Another thing I want to accomplish is to add a Java parameter to the server (I usually do this through the ConfigTool, I click on my instance, change the tab in the right side to Server, and add a line in the text box). Do you know if I can do this by script as well?

Again, Thank you!

Nir

Former Member
0 Kudos

Hey Nir,

Regarding the DBPOOL if I understand you correctly,

open telnet and type add

it should give you all the available group commands

make sure you jump to the server. The default is that you are under the dispatcher which deos not contain the DBPool command and this is probably why you got the error message.

regarding how to run a script:

under the folder :

D:\usr\sap\(instance)\SYS\profile you can find a script

called START_JCOO_(host name).

This script is the one that runs when you

invoke the startup framework and there you

can place some scripts to run

By the way, where are you located?

Regards,

Udi

iavor_petkov
Explorer
0 Kudos

Hi Nir,

Sorry for the late reply - I hope it will still be of value for you (I don't care about the points - 10x is enough :).

About 1 - 10x to Udi you already know the answer - you have forgotten to jump to the server - Note 531293 described how to get the access to the server console (valid also for 6.40).

About 2 - Once having access to the server console you can invoke various commands from the added groups -

MAN

will give you a list of currently available

ADD

will give you a list of what you can use in addition

What you can use besides the commands provided with the Engine is scripts you write yourself.

Scripts are files in the server directory (server0 if you have a single) to which you have jumped. So it is good to have the script distributed to all serverX directories (directly in serverX, not in any subdir of it)

These scripts have the .scr extension and Windows (wrongly) tries to map them as screensavers

In fact they are collection of shell commands that are

supposed to be invoked in a group. You can actually write pretty sophisticated constructs using the shell language - there is if , for etc, but I doubt you will ever need that (At least it was always easier for me to hack a Java class file as command into the shell service rather than tackle with yet another language).

sample script:

#lists all applications in stopped status

add deploy

list_app | grep STOPPED

About 3 - How to run it :

telnet localhost 50308

Administrator

<mypass>

jump 0

run myscript

The output is : sap.com/tcwdeptests STOPPED! Server 0 3_29742

About 4 - it depends. Normally not. In any case not from the runtime of the Engine (and the files with .scr extension)

When the Engine starts it bootstraps its parameters from the DB and fills instance.properties. Later the data in instance.properties is used from jcontrol to start the jlaunch (JVM) processes. Hence if you switch off bootstrap and modify instance.properties and start the Engine (all that in an OS script) we can assume this task is

possible. Otherwise - not.

However as this is a very dangerous activity - you might forget to return the state back to what it used to be and patch/upgrade will fail because data needs to be taken from database - I believe the option of using the configtool is much better.

Hope this helps a bit

Best Regards: Iavor

Answers (3)

Answers (3)

Former Member
0 Kudos

Sorry for reactivating this old thread. I had the same problem as Nir and I wrote a little Perl script. This script automatic login over telnet to your SAP J2EE engine and can run any command. In the code listing below I restart a application. Maybe this is useful for you and all people who will find this thread over the search. It will work under Windows and *nix. Change the first line to your Perl interpreter.

[code]

#!C:\Perl\bin\perl.exe

######################################################

#

  1. Nils Knieling; Mittwoch, 15. November 2006 08:54:12

#

  1. Do something automatic, like stopping and starting

  2. of a application.

#

######################################################

use Net::Telnet;

use strict;

            1. USER VARIABLES START HERE ######

  1. Your SAP J2EE Engine Host

my $host = 'sapdbesh';

  1. SAP Telnet Port 5<SID>08

my $port = '54508';

  1. Login

my $user = 'espadm';

  1. JUMP to Server 0

my $jump = 'jump 0';

  1. Application

my $app = 'sap.com/crm.b2c';

  1. What should this script do?

my @dothis = (

'version',

'info',

'add deploy',

"stop_app $app",

"start_app $app",

);

  1. Print telnet commands and output 0 = No | 1 = Yes

my $echo = '1';

            1. USER VARIABLES END HERE ######

my @output = ();

my $telnet = new Net::Telnet ( Timeout=>10, Port => $port, Errmode=>'die');

print "\n\Uopen telnet connection: $user\@$host:$port\n\n" unless ($echo == '0');

print "Password for user \"$user\"? (The password will show as clear text)\n" unless ($echo == '0');

my $password = <STDIN>; # You can enter the password here

chomp($password);

  1. Open connection

  2. See SAP Note: 531293

$telnet->open($host);

$telnet->waitfor('/login: /i');

print "\n\Usend login\n" unless ($echo == '0');

$telnet->print("$user");

$telnet->waitfor('/password: /i');

print "\n\Usend password\n" unless ($echo == '0');

$telnet->print($password);

print "\n\Ulogin ok !\n\n" unless ($echo == '0');

$telnet->waitfor('/\>/i');

$telnet->print("$jump");

@output = $telnet->waitfor('/\>\>/i');

for (@output) {

print "$_\n" unless ($echo == '0');

}

  1. JUST DO IT [tm]

for (@dothis) {

$telnet->print("$_");

@output = $telnet->waitfor('/\>/i');

for (@output) {

print "$_\n" unless ($echo == '0');

}

}

print "\n\Uclose connection\n" unless ($echo == '0');

$telnet->print("exit");

unless ($echo == '0') {

print "\n\Ufine\n\n\n";

my $end = <STDIN>;

}

[/code]

Regards from Hamburg Germany

-- Nils

Former Member
0 Kudos

Hi Iavor and Udi.

Thanks a lot for your help, and sorry about the delay of my response.

Your answers were very helpful though they did not fully solved the whole task I wanted to do.

I guess I'll post a new message when this becomes critical to us, specifying the remaining issues.

In the meantime, thanks a lot guys!

and Udi - I'm located in Tefen.

iavor_petkov
Explorer
0 Kudos

Hi Nir,

For start and stop of the Engine - check Note 748713.

in the attached pdf there is a script for stopping through the jcmon:

#!/bin/csh

set SAPSYSTEMNAME= <SID>

set SAPSYSTEM= <##>

switch ( `uname` )

case "HP-UX":

setenv SHLIB_PATH /usr/sap/$/j2ee/j2ee_$/os_libs setenv LD_PRELOAD libjvm.sl breaksw case "AIX": setenv LIBPATH /usr/sap/$/j2ee/j2ee_$/os_libs breaksw case "Linux": case "SunOS": setenv LD_LIBRARY_PATH /usr/sap/$/j2ee/j2ee_$/os_libs

breaksw

endsw

cd /usr/sap/$/j2ee/j2ee_$/os_libs ./jcmon pf=/usr/sap/$/global/profile/jcontrol_$.pfl > jcmon.out << EOT

20

2

y

0

0

EOT

There are however issues with input redirection on Windows so be careful.

(The Note is for 6.20 but principle is the same).

For the automation of the JDBC connector creation - check the shell command reference at :

http://aiokeh.wdf.sap.corp:1080/SAPIKS2/logonFromUrl.sap?_SCLASS=IWB_STRUCT&_SLOIO=7F3C6A2BA916FE4BA...

You can write the commands in a text file (myscript.scr), put it into

the server directory and then having jumped to the server from telnet, invoke the script :

run myscript

Full automated telnet , jump and invocation of the script I haven't tried, but I hope the above helps a bit.

Best Regards: Iavor