1

I want to execute a pyz file over SSH in this way:

cat test.pyz | ssh -M user@somehost python

This is the current output:

  File "<stdin>", line 1
    PKimport sys
      ^
SyntaxError: invalid syntax

After some digging, I discovered that if I try: cat test.pyz | python OR python < test.pyz on my terminal I get the same error message.

If I try this: python test.pyz Python successfully executes the bundle. Sadly, this is not an option for me.

Any ideas why and how to successfully run my pyz bundle (in the cat | python fashion)?

ps. The pyz file prints "Hello World" --that's it

subzero
  • 3,420
  • 5
  • 31
  • 40
  • Is this supposed to be an executable zip archive? You can't run those from stdin. – user2357112 Jun 02 '20 at 23:04
  • It's true that the file has the "PKImport sys" at the start. But Python doesn't complain if I execute the pyz file in this way: "python test.pyz". Question edited to reflect this update. – subzero Jun 02 '20 at 23:06
  • zipapps do not work over stdin – anthony sottile Jun 02 '20 at 23:11
  • `python test.pyz` and `cat test.pyz | python` are very different things. The first one tells python "hey, here's this file name, run it". The second one says "here's this long stream of text, run that". Second option is not supported for zipapp. – A-y Jun 02 '20 at 23:26

0 Answers0