我在bash shell 脚本中使用带有特殊字符(例如 $)的密码时遇到了一些麻烦。
我的 shell 脚本是:
read -s -p "Password : " bindDNPass
ldapadd -H ldap://localhost -x -w $bindDNPass -D "dn=cn=Admin" -f /tmp/file.ldif
Run Code Online (Sandbox Code Playgroud)
密码可能类似于 $Something18$。
嗯,命令
ldapadd -H ldap://localhost -x -W -D "dn=cn=Admin" -f /tmp/file.ldif`
Run Code Online (Sandbox Code Playgroud)
要求我的$Something18$,并且工作正常。
但如果我尝试
ldapadd -H ldap://localhost -x -w $Something18$ -D "dn=cn=Admin" -f /tmp/file.ldif
Run Code Online (Sandbox Code Playgroud)
它不起作用。我猜它正在尝试解析变量,$Something18,所以我尝试使用\$Something18$, \$Something18\$, \\\$Something18$, ... 但它一直失败...
我能怎么做?(无需更改密码...)
我面临无法解决的Spring Boot配置问题...我正在尝试使用Spring Boot为HbbTV构建HelloWorld示例,因此我需要使用mime-type =为我的“ index.html”页面提供服务“ application / vnd.hbbtv.xhtml + xml”
我的index.html将作为静态页面访问,例如http://myserver.com/index.html?param=value。
使用以下代码,无论我多么努力,都会得到一个text / html内容类型。
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//HbbTV//1.1.1//EN" "http://www.hbbtv.org/dtd/HbbTV-1.1.1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>MyApp HBBTV</title>
<meta http-equiv="content-type" content="Content-Type: application/vnd.hbbtv.xhtml+xml; charset=UTF-8" />
</head>
<body>
...
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
因此,我尝试在@Controller中添加“ home()”终结点以强制使用正确的mime类型,并且可行。
@RestController
public class HbbTVController {
@RequestMapping(value = "/hbbtv", produces = "application/vnd.hbbtv.xhtml+xml")
String home() {
return "someText";
}
...
}
Run Code Online (Sandbox Code Playgroud)
“有效”表示码头服务器为我提供了一个包含测试someText的正确内容类型的html文件。
我的下一个尝试是将@RestController替换为@Controller(相同的生产配置),并将“ someText”替换为index.html
@Controller
public class HbbTVController {
@RequestMapping(value = "/hbbtv", produces = "application/vnd.hbbtv.xhtml+xml") …Run Code Online (Sandbox Code Playgroud) 我看这个问题:斯卡拉:公共静态最后一类,这一次,太:http://www.scala-lang.org/old/node/9178但我不能让它工作...
我要做的是与以下Java代码等效的Scala:
public class MyClass extends AnotherClass{
public static final String WSDL = MyConfig.getProp("...");
public static final String SERVICES = {new QName(MyConfig.getProp("..."))};
public MyClass(){
super(WSDL,SERVICES);
}
}
Run Code Online (Sandbox Code Playgroud)
我试过了,根据我搜索,方法是:
class MyClass (wsdl: String, services: Array[QName])(implicit val config:MyConfigClass) extends AnotherClass(wsdl,services:_*){
val WSDL:String = config.getProp("...")
val SERVICES: Array[QName] = Array(new QName(config.getProp("...")))
def this() {
this(WSDL,SERVICES:_*)
}
}
Run Code Online (Sandbox Code Playgroud)
但是Scala IDE告诉我WSDL和SERVICES未知。在这一点上声明WSDL和服务是不应该是为Java MyClass.WSDL访问相同呢?
感谢您的任何解决办法,对于任何解释,使我的Scala更易消化...