Fish shell input redirection from subshell output
Asked Answered
S

2

7

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?

Selie answered 10/6, 2016 at 16:37 Comment(0)
E
1

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 -
Enyedy answered 11/6, 2016 at 13:52 Comment(1)
@Olivo 's answer didn't work for me, the behavior was still the same (Wireshark window did not display locally), maybe there's something else missing... This did it though, thanks.Selie
O
16

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)
Olivo answered 10/6, 2016 at 16:53 Comment(2)
According to the documentation, there's no fish equivalent to >(ls)Cheddar
@glennjackman - Correct, thanks, and i was confident that i tested it. (psub|cat) does not fail, but it gives the temporary FIFO name not a stream.Olivo
E
1

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 -
Enyedy answered 11/6, 2016 at 13:52 Comment(1)
@Olivo 's answer didn't work for me, the behavior was still the same (Wireshark window did not display locally), maybe there's something else missing... This did it though, thanks.Selie

© 2022 - 2024 — McMap. All rights reserved.