- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试从 this question 运行命令:
exec 2> >(logger -t myscript)
它在我的桌面 linux 系统上运行良好,但是,在我的嵌入式 linux 设备上,相同的命令会出现以下错误:
-sh: syntax error near unexpected token `>'
所以我猜我的 shell 不喜欢命令语法的一部分——很可能是这一部分:
exec 2>
>(logger -t myscript)
事实上,虽然我知道 2>
正在重定向 stderr
我实际上并不理解第二个 >
字符的语法在这种情况下,它是表示管道的另一种方式吗?
如果我能理解它在做什么,那么也许我可以修改我的命令以在嵌入式 linux 设备上使用我有限的 shell。
最佳答案
所讨论的语法仅适用于 bash(或其他带有 ksh 扩展名的 shell)。在错误中
-sh: syntax error near unexpected token `>'
...您正在尝试将该语法与 /bin/sh
一起使用.
确保您的脚本以 #!/bin/bash
开头,并且您使用 bash yourscript
调用它而不是 sh yourscript
.
更多解释:
>(foo)
被替换为文件名(如果支持,格式为 /dev/fd/##
,否则为命名管道),该文件名接收来自名为 foo
的进程的输出. 这是需要 bash 或 ksh 扩展的部分。exec <redirection>
对当前 shell 进程应用重定向(因此,exec 2>stderr.log
将所有 stderr 从当前命令及其子命令重定向到文件 stderr.log
)。因此,exec 2> >(foo)
修改(当前 shell session 的)stderr 文件描述符以转到命令 foo
的标准输入;在这种情况下,foo
是logger -t myscript
,从而将进程的标准错误发送到系统日志。
要在更有限(但仍然符合 POSIX)的 shell 上执行相同的操作:
# note: if any security concerns exist, put the FIFO in a directory
# created by mktemp -d rather than hardcoding its name
mkfifo /tmp/log.fifo # create the FIFO
logger -t myscript </tmp/log.fifo & # start the reader in the background first!
exec 2>/tmp/log.fifo # then start writing
rm -f /tmp/log.fifo # safe to delete at this point
关于linux - 内嵌shell不支持重定向: exec 2>>(logger -t myscript),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28843312/
如果 Rmd 文件中的 R 代码重复使用相同的变量名,则内联 r 表达式似乎返回此变量的最后一个值,而不管内联表达式的位置。除了确保不在文档的不同部分重复使用相同的变量名称之外,是否可以避免这种行为?
我希望多行文本像单个文本 block 一样环绕,例如下面的“Source”和“DEC”字段,而不使用表格。 我想我应该能够使用 inline-block 来让它工作,但我没有成功。 下面是我正在使用的
我不熟悉Inline Anchor styles(link) ,怎样才能让它的作品展现时尚呢? Javascript/JQuery 编码或遗漏了什么? [ http://codepen.io/anon
我正在尝试将嵌入式 ruby 添加到我的 css 样式宽度标签中。 这是目前代码的样子: %"> 不确定我是否只是搞砸了目标变量,或者我的 float 是否已关闭(它正在打印正确的百分比),但
我想制作一个时间轴,但它的结构已损坏。我认为这是因为 display:inline,如果我试图对我的网站这样做,它会破坏它。display: inline-block 也让它变得有趣。 我尝试将 di
这个问题在这里已经有了答案: How to remove the space between inline/inline-block elements? (41 个回答) 关闭 7 年前。 不确定我
我正在尝试使用嵌入式 UIStackViews 来获得如下所示的内容: Label1 ----------------Label2 Label3 -- 所以我在一个水平 UIStackView 中有
是否可以在使用内联 CSS 的同时创建一个盒子模型 hack? 例如: 谢谢! 最佳答案 您也可以在内联样式中使用“前缀”技巧: 只需确保将 IE hack 放在样式属性的末尾即可。然而,我同意尽
有没有人有什么技巧可以在页面上对齐这两个按钮?默认情况下,iframe 版本的 facebook like 按钮显示在 google plus 按钮下方,反之亦然。是否有任何 CSS 技巧可以使它们保
这就是我想要实现的目标。我有一个运行 Suricata 的内联 linux 盒子,能够丢弃数据包。这适用于将所有流量放到 NFQUEUE 0 上然后设置 suricata 监听的标准方法。 我正在编写
我目前正在将元素中的一个页面导出到 Excel,这将不允许链接外部内容,例如外部 CSS。 我想要实现的是一种在我的 View 中包含 CSS 文件但直接从 Visual Studio 自动缩小的 C
在一个两列的框中(column-count: 2),CSS 设置break-inside: avoid 应该避免一些内容从一列中断到其他。这在 Firefox 和 Chrome 中运行良好(使用适当的
几乎完成了我的登录脚本,只需要帮助寻找替代方法: return (mysql_result($query, 0) == 1) ? true : false; 查询: $query = mysqli_q
我正在尝试获取一个具有嵌入式 Tomcat 服务器的 Spring Boot jar,以在运行时加载外部 war 。我正在尝试使用此 post 中显示的技术来执行此操作. Spring Boot应用中
我正在开发 Spring Boot 1.4 应用程序,并且正在为我的 Rest 端点编写集成测试。我正在使用新的测试注释,如下所示: @RunWith(SpringRunner.class) @Spr
我是一名优秀的程序员,十分优秀!