Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 从powershell调用wlst/jython_Python_Powershell_Jython_Wlst - Fatal编程技术网

Python 从powershell调用wlst/jython

Python 从powershell调用wlst/jython,python,powershell,jython,wlst,Python,Powershell,Jython,Wlst,我想使用参数从powershell调用wlst/jython脚本。(这是一个简化版本) 你好,ps1 param ( [string]$cmd = "none" ) echo "cmd - $cmd" Switch ($cmd) { "hello" { Write-Host "Start hello ..." $script='C:\_WORK_\hello.py' & java -cp

我想使用参数从powershell调用wlst/jython脚本。(这是一个简化版本)

你好,ps1

 param (
    [string]$cmd = "none"
 )

echo "cmd - $cmd"
Switch ($cmd) {
     "hello" {
             Write-Host "Start hello ..."
             $script='C:\_WORK_\hello.py'
             & java -cp C:\bea\tpc\WEBLOG~1\server\lib\weblogic.jar weblogic.WLST $script
         }
     "main" {
             Write-Host "w main $cmd" 
             $cmd='-c "hello"'
             $script="C:\_WORK_\hello_main.py"
             Write-Host "script: $script"
             & java -cp C:\bea\tpc\WEBLOG~1\server\lib\weblogic.jar weblogic.WLST $script $cmd
     }
     Default {Write-Warning "Invalid Choice. Try again."
                  sleep -milliseconds 750}
    } #switch
你好,派伊

print "Hello without main/args"
你好

import getopt

def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "hc:v", ["help", "command="])
    except getopt.GetoptError, err:
        # print help information and exit:
        print str(err) # will print something like "option -a not recognized"
        usage()
        sys.exit(2)
    command = None
    verbose = False
    for o, a in opts:
        if o == "-v":
            verbose = True
        elif o in ("-h", "--help"):
            usage()
            sys.exit()
        elif o in ("-c", "--command"):
            command = a
        else:
            assert False, "unhandled option"
    print 'command: '+command
    if (command == 'hello'):
        print "if hello"

if __name__ == 'main':
    main()
使用“hello.ps1-cmd main”时,脚本在“print”命令“+command”后终止 我不明白为什么

>powershell c:\_WORK_\SAS\hello.ps1 -cmd main
cmd - main
w main main
script: C:\_WORK_\SAS\hello_main.py

Initializing WebLogic Scripting Tool (WLST) ...

command:  hello

>powershell c:\_WORK_\SAS\hello.ps1 -cmd hello
cmd - hello
Status ...

Initializing WebLogic Scripting Tool (WLST) ...

Hello without main/args
 "main" {
         Write-Host "w main $cmd" 
          $arg0 = "C:\_WORK_\SAS\hello_main.py"
          $arg1 = "-c"
          $arg2 = "hello"

          $allArgs = @($arg0, $arg1, $arg2)

         & java -cp C:\bea\tpc\WEBLOG~1\server\lib\weblogic.jar weblogic.WLST $allArgs