我正在尝试从已作为变量读入我的脚本的xml文档中提取值.原始变量$ data是:
<item>
<title>15:54:57 - George:</title>
<description>Diane DeConn? You saw Diane DeConn!</description>
</item>
<item>
<title>15:55:17 - Jerry:</title>
<description>Something huh?</description>
</item>
Run Code Online (Sandbox Code Playgroud)
我希望提取第一个标题值,所以
15:54:57 - George:
Run Code Online (Sandbox Code Playgroud)
我一直在使用sed命令:
title=$(sed -n -e 's/.*<title>\(.*\)<\/title>.*/\1/p' <<< $data)
Run Code Online (Sandbox Code Playgroud)
但这只输出第二个标题值:
15:55:17 - Jerry:
Run Code Online (Sandbox Code Playgroud)
有谁知道我做错了什么?谢谢!
我正在尝试按照本教程创建一个简单的REST Web服务,但是我可以在tomcat上部署它并抛出异常:
FAIL - Application at context path /restful could not be started
FAIL - Encountered exception org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restful]]
Run Code Online (Sandbox Code Playgroud)
我看了看周围的解决方案,发现这个问题,这一个,他们让我觉得这是一个servlet的映射问题但是我不知道如何解决它!
这是我的日志文件:
18/12/2012 9:57:16 AM org.apache.catalina.startup.HostConfig deployWAR
SEVERE: Error deploying web application archive /opt/tomcat7/webapps/restful.war
java.lang.IllegalStateException: ContainerBase.addChild: start:
org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/restful]]
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:904)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:633)
at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:977)
at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1655)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
Run Code Online (Sandbox Code Playgroud)
这是我的web.xml文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app
xmlns="http://java.sun.com/xml/ns/javaee" …Run Code Online (Sandbox Code Playgroud) 我在运行Powershell版本2的服务器上:
PS C:\> $PSVersionTable
Name Value
---- -----
...
PSVersion 2.0
Run Code Online (Sandbox Code Playgroud)
然后,我创建一个到另一台计算机的新远程会话并连接到它:
$sess = New-PSSession -ComputerName {ComputerName} -Credential $credential
Run Code Online (Sandbox Code Playgroud)
它返回结果:
PS C:\> Invoke-Command -Session $sess -ScriptBlock { $PSVersionTable }
Name Value
---- -----
...
PSVersion 3.0
Run Code Online (Sandbox Code Playgroud)
但是,我需要Powershell在我的脚本的版本2中,所以我进入一个会话(以使其更容易).然后我尝试让Powershell成为第2版:
C:\> Enter-PSSession -Session $sess
[{ComputerName}]: PS C:\> Powershell -Version 2
Windows Powershell
Copyright (C) 2009 Microsoft Corporation. All rights reserverd
Run Code Online (Sandbox Code Playgroud)
然后它就会挂起(或者至少从来没有让我在控制台中输入任何其他内容,直到我按Ctrl-C).
我也尝试过通过Invoke-Command:
PS C:\> Invoke-Command -Session $sess -ScriptBlock { Powershell -version 2 }
Run Code Online (Sandbox Code Playgroud)
它也是如此.
我还尝试按照此处注册PSSessionConfiguration:https://technet.microsoft.com/en-us/library/hh847899.aspx
PS C:\> Register-PSSessionConfiguration -Name PS2 …Run Code Online (Sandbox Code Playgroud)