简体   繁体   English

鱼壳输入从子壳输出重定向

[英]Fish shell input redirection from subshell output

When I want to run Wireshark locally to display a packet capture running on another machine, this works on bash, using input redirection from the output of a subshell: 当我想在本地运行Wireshark以显示在另一台机器上运行的数据包捕获时,这适用于bash,使用来自子shell输出的输入重定向:

wireshark -k -i <(ssh user@machine "sudo dumpcap -P -w - -f '<filter>' -i eth0")

From what I could find, the syntax for similar behavior on the fish shell is the same but when I run that command on fish, I get the Wireshark output on the terminal but can't see the Wireshark window. 根据我的发现,fish shell上类似行为的语法是相同的但是当我在fish上运行该命令时,我在终端上获得了Wireshark输出,但是看不到Wireshark窗口。

Is there something I'm missing? 有什么我想念的吗?

What you're using there in bash is process substitution (the <() syntax). 你在bash中使用的是进程替换<()语法)。 It is a bash specific syntax (although zsh adopted this same syntax along with its own =() ). 它是一种特定bash的语法(虽然zsh采用了相同的语法及其自己的=() )。

fish does have process substitution under a different syntax ( (process | psub) ). fish确实在不同的语法下进行了进程替换(process | psub) )。 For example: 例如:

wireshark -k -i (ssh user@machine "sudo dumpcap -P -w - -f '<filter>' -i eth0" | psub)

bash        | equivalent in fish
----------- | ------------------
cat <(ls)   | cat (ls|psub)
ls > >(cat) | N/A (need to find a way to use a pipe, e.g. ls|cat)

The fish equivalent of <() isn't well suited to this use case. 相当于<()的鱼不太适合这种用例。 Is there some reason you can't use this simpler and more portable formulation? 有什么理由你不能使用这种更简单,更便携的配方?

ssh user@machine "sudo dumpcap -P -w - -f '<filter>' -i eth0" | wireshark -k -i -

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM