Passing resulted string name of a gzipped file as an argument to another piped tool

Hi,

I have a .pcap.gz file and I would like to initially gzip it and then pass the resulting .pcap filename as an argument to a piped tool; the right-hand tool is not standardized linux tool but a custom one that strictly requires the string name of a given .pcap file in order for the pcap file to be processed. Anyhow,

For example, the tool works fine if i state the following on an already unzipped file :

./my_tool -I -C source="file.pcap" > text_format_of_pcap

I've tried the following just to check on whether it would work directly on a gzipped (however as anticipated it didn't):

gzip -c myfile.pcap.gz > ../mydirectory/ | my_tool -I -C 

Therefore, I was wondering on whether there is a way to use stdin or something else to do that?

Thanks in advance

Doesn't work that way. It wouldn't have a real file name, in any case; it'd try to open a file and complain that it didn't exist.

A named pipe may be useful. It'll effectively be a file my_tool can open, but acts like a pipe written to by something else.

Whatever process opens it freezes, though, until something else opens it too. So the writing process has to open it in the background.

mkfifo filename.pcap

( exec gunzip < filename.pcap.gz > filename.pcap & )

./my_tool filename.pcap

rm filename.pcap
1 Like

Thank you Corona, it worked just perfect! However, now I need to do this process for a bunch of *.pcap.gz files and I'll try to integrate your suggestion in a shell script. Cheers!

1 Like