wdzeng / shopee-coins-bot

💰 蝦皮簽到機器人 💰
MIT License
441 stars 797 forks source link

無法儲存 cookie #18

Closed dexders closed 2 years ago

dexders commented 2 years ago

image

使用 win10 WSL2 跑 docker。 讀取 cookie 時出現 Failed to load cookies: EISDIR: illegal operation on a directory, read 寫入則是Failed to save cookie: EISDIR: illegal operation on a directory, open '/app/cookie'

wdzeng commented 2 years ago

Hi,

請注意這個錯誤訊息 Failed to save cookie: EISDIR: illegal operation on a directory,這就是說請你不要 mount 在資料夾上。

dexders commented 2 years ago

image

有試過 mount 在其他地方, 但是寫入時出現 Failed to save cookie: EACCES: permission denied, open '/cookie'

wdzeng commented 2 years ago
-v /home/eric/dat:/cookies

你把 cookie 打成 cookies 了。

另外如果可以的話,請貼上文字指令,而不是附上截圖。

dexders commented 2 years ago

很多檔名都試過了 cookie cookies abc, 都出現 Failed to save cookie: EACCES: permission denied

wdzeng commented 2 years ago

很多檔名都試過了 cookie cookies abc, 都出現 Failed to save cookie: EACCES: permission denied

試試看如下。

docker run -it -v xxx:/cookie --user 1000:1000 hyperbola/shopee-coins-bot:1 xxx

如果你的 UID 不是 1000 的話,把上面的 1000 換成你的 UID。

dexders commented 2 years ago
$ id
uid=1000(eric) gid=1000(eric) groups=1000(eric),4(adm),20(dialout),24(cdrom),25(floppy),27(sudo),29(audio),30(dip),44(video),46(plugdev),117(netdev),1001(docker)
$ docker run -it -v /home/eric/dat:/cookie --user 1000:1000 hyperbola/shopee-coins-bot:1.0 -u xxx -p xxx -c cookie

Start shopee coins bot v1.0.17.
Passing password from command line is considered insecure. Should use environment variable or password file.
Start to load cookies.
Failed to load cookies: ENOENT: no such file or directory, open '/app/cookie'
Start to login shopee.
Try to login by username and password.
Login form submitted. Waiting for redirect.
Login failed: please login via SMS.
An SMS message is sent to your mobile. Once you click the link I will keep going. I will wait for you and please complete it in 10 minutes.
Login permitted.
Start to save cookie.
Failed to save cookie: EACCES: permission denied, open '/app/cookie'
Coin already received.

是不是 mount 到了特定資料夾才會這樣?

wdzeng commented 2 years ago

Hi @dexders,

這次的回覆工整且有排版,非常貼心!我收回不再回覆這句話。

是不是 mount 到了特定資料夾才會這樣?

不是。

應該要這樣下才對。

docker run -it -v /home/eric/dat:/cookie --user 1000:1000 hyperbola/shopee-coins-bot:1.0 -u xxx -p xxx -c /cookie
                                                                                                          ^^^^^^^

你的 -c cookie 是有問題的,因為這是 relative path;要下 -c /cookie 才對。

dexders commented 2 years ago

Hi @dexders,

這次的回覆工整且有排版,非常貼心!我收回不再回覆這句話。

是不是 mount 到了特定資料夾才會這樣?

不是。

應該要這樣下才對。

docker run -it -v /home/eric/dat:/cookie --user 1000:1000 hyperbola/shopee-coins-bot:1.0 -u xxx -p xxx -c /cookie

你的 -c cookie 是錯的,這是 relative path;要下 -c /cookie 才對。


$ docker run -it -v /home/eric/dat:/cookie --user 1000:1000 hyperbola/shopee-coins-bot:1.0 -u xxx-p xxx -c /cookie

Start shopee coins bot v1.0.17. Passing password from command line is considered insecure. Should use environment variable or password file. Start to load cookies. Failed to load cookies: EISDIR: illegal operation on a directory, read Start to login shopee. Try to login by username and password. Login form submitted. Waiting for redirect. Login failed: please login via SMS. An SMS message is sent to your mobile. Once you click the link I will keep going. I will wait for you and please complete it in 10 minutes. Login permitted. Start to save cookie. Failed to save cookie: EISDIR: illegal operation on a directory, open '/cookie' Coin already received.



`/cookie` `./cookie` `cookie` 已經試不出東西了,我是不是沒有天分 QQ
wdzeng commented 2 years ago

Hi @dexders,

請注意 EISDIR: illegal operation on a directory 訊息,這表示容器裡的 /cookie 是一個資料夾,但它應該要是檔案才對。

容器裡的 /cookie 對應到你實體機器的 /home/eric/dat,因為 -v /home/eric/dat:/cookie。也就是說,/home/eric/dat 是一個資料夾,對吧?

cookie 必須要是一個檔案,而不是資料夾。假設你希望 cookie 實際上放在 /home/eric/dat/shopee-cookie,你可以這樣做:

docker run -it \
    -v /home/eric/dat:/dat \
    --user 1000:1000 \
    hyperbola/shopee-coins-bot:1.0 -u xxx -p xxx -c /dat/shopee-cookie

這個機器人是設計給熟悉操作 docker 的使用者。如果不熟悉 docker mount 相關的概念的話,操作起來會比較困難,這是正常的。

dexders commented 2 years ago

Hi @dexders,

請注意 EISDIR: illegal operation on a directory 訊息,這表示容器裡的 /cookie 是一個資料夾,但它應該要是檔案才對。

容器裡的 /cookie 對應到你實體機器的 /home/eric/dat,因為 -v /home/eric/dat:/cookie。也就是說,/home/eric/dat 是一個資料夾,對吧?

是的 把主機的 /home/eric/dat mount到容器內的/cookie資料夾

cookie 必須要是一個檔案,而不是資料夾。假設你希望 cookie 實際上放在 /home/eric/dat/shopee-cookie,你可以這樣做:

docker run -it \
    -v /home/eric/dat:/dat \
    --user 1000:1000 \
    hyperbola/shopee-coins-bot:1.0 -u xxx -p xxx -c /dat/shopee-cookie

這個機器人是設計給熟悉操作 docker 的使用者。如果不熟悉 docker mount 相關的概念的話,操作起來會比較困難,這是正常的。

從原先的範例指令來看 docker run -it -v /path/to/somewhere:/cookie hyperbola/shopee-coins-bot:1 -u username -p password -c /cookie 預期是在容器內的/cookie資料夾讀取cookie檔案 因為不確定 -c 後面跟的是只有path還是包含檔名 所以try了好一陣子 但現在已經確定work了

$ docker run -it -v /home/eric/dat:/dat --user 1000:1000 hyperbola/shopee-coins-bot:1.0 -u xxx-p xxx -c /dat/shopee-cookie
Start shopee coins bot v1.0.17.
Passing password from command line is considered insecure. Should use environment variable or password file.
Start to load cookies.
Failed to load cookies: ENOENT: no such file or directory, open '/dat/shopee-cookie'
Start to login shopee.
Try to login by username and password.
Login form submitted. Waiting for redirect.
Login failed: please login via SMS.
An SMS message is sent to your mobile. Once you click the link I will keep going. I will wait for you and please complete it in 10 minutes.
Login permitted.
Start to save cookie.
Cookie saved.
Coin already received.

這樣是不是建議修改一下 帳號密碼登入 改成以下這樣

docker run -it -v /path/to/somewhere:/cookie \
    hyperbola/shopee-coins-bot:1 -u username -p password -c /cookie/cookie

以防像我這樣天分不足的人搞不清楚 XDD

感謝幫忙!

wdzeng commented 2 years ago

@dexders 我沒看懂你的指令,另外你的 markdown 也爛掉了 = =

dexders commented 2 years ago

@dexders 我沒看懂你的指令,另外你的 markdown 也爛掉了 = =

docker run -it -v /path/to/somewhere:/cookie \
hyperbola/shopee-coins-bot:1 -u username -p password -c /cookie/cookie

其實也就是-c /cookie 改成 -c /cookie/cookie 對應 -v /path/to/somewhere:/cookie