Skip to content

[Windows] Running two commands piped together does not work #15

@Sgt-Nukem

Description

@Sgt-Nukem

Preface:

(For the following examples I replaced my personal access token with ABCDEF)

Doing a curl request against the Steam API works of course. Note that I need to quote the URL because of characters like ?, & and \ that would otherwise be (mis-)interpreted by the shell:
curl -s "https://api.steampowered.com/IGameServersService/GetServerList/v1?key=ABCDEF&filter=appid\42120"
Result:

{"response":{"servers":[{"addr":"78.34.130.134:27016","gameport":27015,"steamid":"90282946280681494","name":"Not Barry's either...","appid":42120,"gamedir":"leadandgoldinternalbeta","version":"1.0.0.0","product":"POWDERKEG","region":255,"players":0,"max_players":10,"bots":0,"map":"DEADWATER RANCH","secure":false,"dedicated":true,"os":"w"},{"addr":"89.168.103.250:27016","gameport":27015,"steamid":"90281696798215199","name":"There is a new server in town.","appid":42120,"gamedir":"leadandgoldinternalbeta","version":"1.0.0.0","product":"CONQUEST","region":255,"players":0,"max_players":10,"bots":0,"map":"DEVIL´S PIT","secure":false,"dedicated":true,"os":"w"}]}}

Piping this through jq also works as expected:
curl -s "https://api.steampowered.com/IGameServersService/GetServerList/v1?key=ABCDEF&filter=appid\42120" | jq ".response.servers[].name"
Result:

"Not Barry's either..."
"There is a new server in town."

Using this command chain as an argument to another command fails of course:
echo curl -s "https://api.steampowered.com/IGameServersService/GetServerList/v1?key=ABCDEF&filter=appid\42120" | jq ".response.servers[]"
Result:

jq: parse error: Invalid numeric literal at line 1, column 5

(Explanation: echo returns the curl -s "https://api.steam[..] string which then gets piped into jq which then throws an error because that string is of course not valid JSON.)

If echo is supposed to process the whole rest of the line as argument, I need to escape the pipe (|) symbol, which on Windows is done with a ^:
echo curl -s "https://api.steampowered.com/IGameServersService/GetServerList/v1?key=ABCDEF&filter=appid\42120" ^| jq ".response.servers[]"
Result:

curl -s "https://api.steampowered.com/IGameServersService/GetServerList/v1?key=ABCDEF&filter=appid\42120" | jq ".response.servers[]"

(This works exactly as I would expect now.)

Issue:

Now, replacing the echo with watch, I would expect that watch also takes the whole rest of the line as its argument and runs it periodically:
watch curl -s "https://api.steampowered.com/IGameServersService/GetServerList/v1?key=ABCDEF&filter=appid\42120" ^| jq ".response.servers[]"
Result:

[2026-03-21 13:37:00] Execute [curl -s "https://api.steampowered.com/IGameServersService/GetServerList/v1?key=ABCDEF&filter=appid\\42120" | jq .response.servers[]] every 5s
{"response":{"servers":[{"addr":"78.34.130.134:27016","gameport":27015,"steamid":"90282946280681494","name":"Not Barry's either...","appid":42120,"gamedir":"leadandgoldinternalbeta","version":"1.0.0.0","product":"POWDERKEG","region":255,"players":0,"max_players":10,"bots":0,"map":"PROSPECTOR´S PEAK","secure":false,"dedicated":true,"os":"w"},{"addr":"89.168.103.250:27016","gameport":27015,"steamid":"90281696798215199","name":"There is a new server in town.","appid":42120,"gamedir":"leadandgoldinternalbeta","version":"1.0.0.0","product":"CONQUEST","region":255,"players":0,"max_players":10,"bots":0,"map":"DEVIL´S PIT","secure":false,"dedicated":true,"os":"w"}]}}

(One can clearly see that this is the original curl output which is not further processed by jq at this time.)

Then... after some seconds, it pops this behind the output:

[2026-03-21 13:37:05] Failed with 3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions