- 论坛徽章:
- 0
|
各位:
我有段python脚本,运行时报错,信息如下:
2016-07-12 10:59:14,777 INFO agent: worker uapgv4190.us.oracle.com-0 started
2016-07-12 10:59:16,186 ERROR uapgv4190.us.oracle.com-0: aborting process - Jython exception, <type 'exceptions.SyntaxError'>: ("no viable alternative at input '/'", ('./test_ldap.py', 70, 15, " f = open(/tmp/ldaptest.log, 'a+')\n")) [initialising test script]
net.grinder.scriptengine.jython.JythonScriptExecutionException: <type 'exceptions.SyntaxError'>: ("no viable alternative at input '/'", ('./test_ldap.py', 70, 15, " f = open(/tmp/ldaptest.log, 'a+')\n"))
2016-07-12 10:59:16,197 INFO agent: finished
我的脚本就是不断运行ldap search命令,脚本如下:- from net.grinder.script.Grinder import grinder
- from net.grinder.script import Test
- from datetime import datetime
- from datetime import timedelta
- import os
- import sys
- ########################################
- #
- # main body of test script starts here
- #
- ########################################
- # Get the propeties to access test configuration information
- properties = grinder.getProperties()
- # The description is a property (instead of a hardcoded string in this script)
- test = Test(1, properties.get("javatest.description"))
- # select the method for which to collect information
- #test.record(WriteMulitpleLittleFile.write)
- # initialize data for compressing
- #fileName = properties.get("javatest.fileToCompress")
- #grinder.logger.info("data file to compress is " + fileName)
- #JavaTest.initializeCompression(fileName)
- # If the run mode is runOnce, the TestRunner class will
- # run once. Otherwise, if the run mode is continuous,
- # the TestRunner class will run the test for at least
- # the specified duration (but possibly longer)
- runMode = properties.get("javatest.runMode")
- #WriteMulitpleLittleFile.setParameters(dir, fileSize...)
- if runMode == "continuous":
- # figure out how long to run the test
- m = int(properties.getProperty("javatest.durationMinutes", "0"))
- h = int(properties.getProperty("javatest.durationHours", "0"))
- d = int(properties.getProperty("javatest.durationDays", "0"))
- duration = timedelta(minutes=m,hours=h,days=d)
- grinder.logger.info("run mode is continuous, duration is " + str(duration))
- elif runMode == "runOnce":
- grinder.logger.info("run mode is run once")
- duration = timedelta(minutes=0)
- else:
- grinder.logger.info("run mode not set or not recongized, default to run once")
- duration = timedelta(minutes=0)
- ########################################
- #
- # The TestRunner class is used by The Grinder to perform the test
- #
- ########################################
- grinder.statistics.registerSummaryExpression("connTimeout", "userLong4")
- class TestRunner:
- def __call__(self):
- endTime = datetime.now() + duration
- notDone = True
- while notDone:
- notDone = datetime.now() < endTime
- os.environ['ORACLE_HOME'] = "/u03/Middleware/Oracle_IDM"
- from commands import getoutput
- result = getoutput( '/u03/Middleware/Oracle_IDM/bin/ldapsearch -a always -D cn=orcladmin -w welcome1 -p 3060 -b "" -s sub "objectclass=*" orcldirectoryversion ou=Groups Privilege, cn=OperationURLs,cn=DAS,cn=Products,cn=OracleContext,dc=cn,dc=oracle,dc=com')
- #print result
- f = open(/tmp/ldaptest.log, 'a+')
- f.write(result)
- f.close()
- def recordconnTimeout(connTimeout):
- grinder.statistics.forCurrentTest.setValue("userLong4", connTimeout)
复制代码 以前脚本输出显示先屏幕上运行正常,添加了一段代码把查询信息输出在文件里就报错了,添加的代码如下:- f = open(/tmp/ldaptest.log, 'a+')
- f.write(result)
- f.close()
复制代码 不知道哪里写错了? 请指点下 谢谢
|
|