我有一个bash脚本(source),它必须将openssl输出重定向到另一个bash脚本:
stdbuf -i0 -o0 \
openssl s_client \
-starttls xmpp \
-xmpphost "$domain" \
-connect "$host:$port" \
-quiet \
< "$pipename" \
| (printf '%s %s\n' "$jid" "$authstr"; \
stdbuf -o0 tr '>\n' '\n\001') \
| stdbuf -o0 tee "$debug_recv" \
| stdbuf -o0 "$thisdir/echoz.sed" \
| stdbuf -o0 tee "$debug_sent" \
| stdbuf -o0 tr -d '\n' \
| stdbuf -o0 tr '\001' '\n' \
| tee >( bash commandparser.sh >> /dev/pts/0 ) \
> "$pipename"
但它给出了一个错误:./echoz.sh: 38: Syntax error: "(" unexpected
如果我在命令行中做同样的事情,它工作得很好:
$ echo "[DATA]" | tee >( bash commandparser.sh >> /dev/pts/0 )
------------------NEW MESSAGE-----------------
From:
To:
Type:
Text:
------------------NEW MESSAGE-----------------\n\n
2条答案
按热度按时间kyvafyod1#
Your script以
#!/bin/sh
开头,并且sh
不一定是bash
。如果希望脚本以bash
运行,则使用#!/usr/bin/env bash
。z6psavjg2#
通过ShellCheck.net运行它。
你的问题可能就像艾德说的那样-
sh
* 可能 * 是bash
-我的Git Bash模拟器的sh
允许>(...)
结构,但其他版本可能不允许,所以我会显式使用bash
,或者检查以确认目标系统的sh
可以处理所有这些功能。我也会努力减少剧本中的“噪音”。