How do I include a shell variable in my script?

2008-07-29 Thread laredotornado
Hi,

I'm running a Python script on a Solaris 9 machine, invoking the
Python script from ksh, if that matters.  There is an enviornment
variable, $JAVA_HOME, that I would like to include in my script,
replacing "/path/to/java/home'" with the value of $JAVA_HOME.

java_home='/path/to/java/home'

How do I do this?  If I need to pass a command line argument, so be
it, but I figure there is a more direct way to get the value.

Thanks, - Dave
--
http://mail.python.org/mailman/listinfo/python-list


Syntax error in my script

2008-07-30 Thread laredotornado
Hi,

This might be more relevant for another group, but since this is a
Python script, thought I'd start here.  I'm trying to write a WLST
script for WebLogic 9.2. I coped one directly from WebLogic's site
(http://e-docs.bea.com/wls/docs90/config_scripting/
using_WLST.html#1078952), but I'm getting errors.  Specifically, I'm
getting

$HOSTNAME:"$PWD"->sh run_setup_cluster.sh

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

Problem invoking WLST - Traceback (innermost last):
(no code object) at line 0
File "/export/third-party/etsbea/home/etsbea/tests/npsconfig/
createcluster.py", line 2
from javax.management import *
^
SyntaxError: invalid syntax


Below is my script. I know nothing about Python but cutting and
pasting from BEA's site isn't cutting it.

Begin createcluster.py file===
from java.util import *
from javax.management import *
import javax.management.Attribute

print 'starting the script  '

connect('system','weblogic','t3://localhost:7001')
clusters = "NPSCONFIG_GUI_Cluster"
ms1 = {'managed1':7019:8020,'managed2':7020:8021}

clustHM = HashMap()
edit()
startEdit()

for c in clusters:
print 'creating cluster '+c
clu = create(c,'Cluster')
clustHM.put(c,clu)
cd('Clusters/' + c)
set('MulticastAddress', '237.0.0.101')
set('MulticastPort', 9200)
set('WeblogicPluginEnabled', 'true')

cd('..\..')

clus1 = clustHM.get(clusters[0])

for m, lp, ssl_lp in ms1.items():
managedServer = create(m,'Server')
print 'creating managed server '+m
managedServer.setListenAddress('10.61.6.134')
managedServer.setListenPort(lp)
managedServer.setEnabled(0)
cd('SSL/cgServer')
managedServer.setEnabled(1)
managedServer.setListenPort(ssl_lp)
managedServer.setCluster(clus1)

save()
activate(block="true")
disconnect()
print 'End of script ...'
exit()
==End cretaecluster.py file===
--
http://mail.python.org/mailman/listinfo/python-list


Re: Syntax error in my script

2008-07-30 Thread laredotornado
On Jul 30, 11:26 am, Alan Franzoni
<[EMAIL PROTECTED]> wrote:
> laredotornadowas kind enough to say:
>
> [cut]
>
> Indentation counts in Python. You're probably doing something wrong with
> whitespace/tab/carriage return.
>
> --
> Alan Franzoni <[EMAIL PROTECTED]>
> -
> Remove .xyz from my email in order to contact me.
> -
> GPG Key Fingerprint:
> 5C77 9DC3 BD5B 3A28 E7BC 921A 0255 42AA FE06 8F3E

That was it.  Thanks, -
--
http://mail.python.org/mailman/listinfo/python-list


Possible to have multiple loop variables?

2008-07-30 Thread laredotornado
I don't know why I thought this would work, but I would like to have 3
variables in my for loop per iteration.  Those familiar will know that
this

ms1 = {'managed1':7019:8020,'managed2':7020:8021}
for m, lp, ssl_lp in ms1.items():
  managedServer = create(m,'Server')
  print 'creating managed server '+m
  managedServer.setListenAddress('147.191.71.70')
  managedServer.setListenPort(lp)
  managedServer.setEnabled(0)
  cd('SSL/cgServer')
  managedServer.setEnabled(1)
  managedServer.setListenPort(ssl_lp)
  managedServer.setCluster(clus1)

causes

  File "/export/third-party/etsbea/home/etsbea/tests/wlst/
createcluster.py", line 9
ms1 = {'managed1':7019:8020,'managed2':7020:8021}
  ^
SyntaxError: invalid syntax


How would I set up the ms1 array such that I can use three items per
object?

Thanks, - Dave
--
http://mail.python.org/mailman/listinfo/python-list