You should post the error message provided not just the return code. I'm
guessing you received a STAXPythonEvaluationError, because Python code
blocks are defined by their indentation. By "code block", I mean
functions, if statements, for loops, while loops, and so forth. Indenting
starts a block and unindenting ends it. There are no explicit braces,
brackets, or keywords. This means that whitespace is significant, and must
be consistent.
So, if you really have the following Python code within a <script>
element, you'll get a STAXPythonEvaluationError because the line with the
comment (#) does not start at the same indentation as the rest of the
code. And the code after it is also not at the same indentation level.
And the Python function you defined is not indented properly, etc.
Note this is in addition to the comments that David made already about how
STAX V3.4.5 and earlier use Jython 2.1 to execute the Python code.
<script>
import os
import signal
import subprocess
# Change this to your process name
processname = "server"
def findThisProcess(process_name):
ps = subprocess.Popen("ps -eaf | grep "+process_name,
shell=True, stdout=subprocess.PIPE)
output = 'ps.stdout.read()'
ps.stdout.close()
ps.wait()
return output
</script>
--------------------------------------------------------------
Sharon Lucas
IBM Austin, luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313
From: "Raja Narayanan" <v_rajnara...@rediffmail.com>
To: "staf-users " <staf-users@lists.sourceforge.net>
Date: 03/18/2011 08:45 AM
Subject: [staf-users] HOW to run python code in STAX XML Program
Hello Staf-users,
Im trying to run the following python code in STAX XML program within
<script>. But facing RC:4001 error submitting executing request problem.
<script>
import os
import signal
import subprocess
# Change this to your process name
processname = "server"
def findThisProcess(process_name):
ps = subprocess.Popen("ps -eaf | grep "+process_name,
shell=True, stdout=subprocess.PIPE)
output = 'ps.stdout.read()'
ps.stdout.close()
ps.wait()
return output
</script>
Q1: Does the method I have followed is correct or not?
Q2: Do we need to set up python installer path or env variable need to set
before running the python code.
Please help
Thanks,
V Raja
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users