2
        local script = [[
            [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
            Invoke-RestMethod https://raw.githubusercontent.com/MyAcc/MyBranch/main/blabla.lua  -Method Get -Headers @{"Authorization" = "Bearer XXXXXXXXXXXXXXXXXXXXXX"}
            
            ]]
        local pipe = io.popen("powershell -command -","w"):write(script)
        local result = pipe:read('*all')
        pipe:close()
        print(result)

When i run this code it show the raw file from github but the print(result) return as nil why is that ?

This is the error i got and the nil value afterward

1

aynber
  • 22,380
  • 8
  • 50
  • 63
Retaker
  • 33
  • 6

1 Answers1

0

You are opening a pipe that can only be written to ("w"). Lua pipes are one-way pipes. See the reference manual: You can either open a "r" or "w" pipe, but a pipe can't be both at the same time. Thus reading fails by returning nil because there is nothing to read. See also this question on implementing two-way pipes.

Luatic
  • 8,513
  • 2
  • 13
  • 34
  • Hey thanks for the reply, i already look the link you point on how to implementing two way pipes, but i still dont get it how to implement that on my code cause i need to write then read the result afterward – Retaker Oct 12 '22 at 01:25