Run binary file contents from pipe

In short, run a bash compressed script? but can this be done using a binary instead of a shell script?


Suppose I have a binary that compresses in .gz. I can unzip the handset and check the contents like this:

  $ gzip -d --stdout hello.gz |  file -
 / dev / stdin: ELF 64-bit LSB executable, AMD x86-64, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
 $ 

Instead of passing this output to a command, is there a way I can actually execute the contents of the channel itself without writing it to a file?

I have considered using a named pipe, but this does not work:

  $ mkfifo execpipe
 $ chmod 777 execpipe
 $ gzip -d --stdout hello.gz> execpipe &
 [3] 30034
 $ ./execpipe 
 bash: ./execpipe: Permission denied
 $ [3] + Broken pipe gzip -d --stdout hello.gz> execpipe

 $ 

Is there a way to execute the contents of the feed without creating the actual file?

+7
linux shell pipe executable
source share
1 answer

I think the answer is no.

You can execute the file manually by passing it to the Linux bootloader , which will be called /lib/ld-linux.so . * He needs an actual file. He cannot perform a pipe or stdin; it should be able to mmap() file.

 $ /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /bin/true $ /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 - < /bin/true -: error while loading shared libraries: -: cannot open shared object file: No such file or directory $ /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 <(cat /bin/true) /dev/fd/63: error while loading shared libraries: /dev/fd/63: invalid ELF header 

* On my Red Hat machine, this is /lib/ld-linux.so.2 (32-bit) or /lib64/ld-linux-x86-64.so.2 (64-bit). On my Ubuntu machine, this is /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 .

+6
source share

All Articles