vogler / free-games-claimer

Automatically claims free games on the Epic Games Store, Amazon Prime Gaming and GOG.
GNU Affero General Public License v3.0
2.46k stars 149 forks source link

"/bin/sh: 1: -i: not found" (apprise e-mail error) #239

Closed Xansala closed 11 months ago

Xansala commented 11 months ago

Hi, Thanks a lot for this great piece of software! I have set it up on a VPS and claiming works fine so far. There seems to be an issue when sending the notification through e-mail. The following code is used by the free-games-claimer for sending the e-mail based on what I see on the command line:

apprise mailtos://{e-mail account}:{password}@gmx.de?user={e-mail address}&smtp=mail.gmx.com&to={target e-mail} -i html '' -b 'prime-gaming (xxx):<br>- <a href="https://gaming.amazon.com/ghostwire-tokyo-epic/dp/amzn1.pg.item.284738ee-ff78-4097-93b5-4b74e891455f">Ghostwire: Tokyo</a> (failed: need account linking for epic games store)<br>- <a href="https://gaming.amazon.com/golden-light-epic/dp/amzn1.pg.item.f2a06f58-f651-451e-92ef-a6f734641ebb">Golden Light</a> (failed: need account linking for epic games store)'

Which comes back with the following error: /bin/sh: 1: -i: not found and no e-mail is sent.

If I try the generated apprise code directly in command line (putting the mailtos in ""), then I get no error and the e-mail is sent. So the configuration and setup seems to work in general. Does someone else had a similar issue and was able to solve it? Or is coming from the docker image?

blackpanther989 commented 11 months ago

surround your mailtos in quotes EX: "mailtos://{e-mail account}:{password}@gmx.de?user={e-mail address}&smtp=mail.gmx.com&to={target e-mail}"

That fixed it for me.

Xansala commented 11 months ago

Hi @blackpanther989 ,

Thanks for the hint! I am providing the mailtos through the NOTIFY variable, i.e. NOTIFY="mailtos ...". There I am using the quotes and also tried apostrophe but both result in the same error (also double or triple quotes do not work).

docker run --rm -p 6080:6080 -v fgc:/fgc/data --pull=always -e NOTIFY="mailtos://{e-mail account}:{password}@gmx.de?user={e-mail address}&smtp=mail.gmx.com&to={target e-mail}" ghcr.io/vogler/free-games-claimer

blackpanther989 commented 11 months ago

Hi @blackpanther989 ,

Thanks for the hint! I am providing the mailtos through the NOTIFY variable, i.e. NOTIFY="mailtos ...". There I am using the quotes and also tried apostrophe but both result in the same error (also double or triple quotes do not work).

docker run --rm -p 6080:6080 -v fgc:/fgc/data --pull=always -e NOTIFY="mailtos://{e-mail account}:{password}@gmx.de?user={e-mail address}&smtp=mail.gmx.com&to={target e-mail}" ghcr.io/vogler/free-games-claimer

I also had an issue with this as well and it was that my password contained something that broke the parsing. but other then that I wouldn't know what else would be breaking it.

Mine is entered as: "mailtos://{email}?smtp={smtpserver}&user={username}&pass={password}" and I'm using gmail.

Xansala commented 11 months ago

Thanks @blackpanther989, Just tried it again following your scheme but I am getting the same error. The password is an alpha-numeric one, there are no special characters in there.

It looks like that the games claimer script is not putting quotes around the apprise command when executing it and then with the "&" in the command URL, the command line seems to interpret it which results in the error.

vogler commented 11 months ago

https://github.com/vogler/free-games-claimer/blob/a7cc68b6db41a9542684099583c9127a9b703fa9/util.js#L94

NOTIFY was not quoted, so if yours contained something that must be escaped on the shell, it made it fail. You could have put escaped quotes around it. I just switched to execFile which takes arguments as an array, so there should be no more shell-escape issues. (exec just spawned a shell to execute the command whose arguments then need to be properly escaped.)