简体   繁体   中英

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 -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.

Is there something I'm missing?

What you're using there in bash is process substitution (the <() syntax). It is a bash specific syntax (although zsh adopted this same syntax along with its own =() ).

fish does have process substitution under a different syntax ( (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 -

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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