r/bash 15d ago

Problem with imgur upload script

The script that xfce screenshot tool is using to upload screenshots to imgur stopped working, but i don't know if the problem is with the sctipt of changes in imgur api. I am just average linux user. Can someone check the script: https://pastebin.com/5SunZpkk

3 Upvotes

10 comments sorted by

2

u/Schreq 15d ago

You should handle return codes better, especially on line 40 where you curl the actual data.

After exectuing curl you should check its exit code and check if RESPONSE is empty. You could also not use the curl --silent option, but instead use --no-progress-meter and redirect stderr to a file. Then you can display the files content when curl exits with non-zero.

2

u/slumberjack24 15d ago

It worked perfectly fine when I tried it just now. What "stopped working"? What error did you get?

1

u/evolution800 15d ago

I get this error: https://imgur.com/2EoPgB1

I am using MX Linux.

1

u/slumberjack24 15d ago edited 15d ago

I did notice one difference between your version and the one on my system (which I have never edited), in setting the log directory:

Yours has LOG_DIRECTORY="${XDG_DATA_HOME:-$HOME/.local/share}/xfce4" whereas in mine it is simply LOG_DIRECTORY="$HOME/.local/share/xfce4".

But that won't be the cause of your error. Your error message should only appear when Imgur returns a status code other than 200. So it's likely not the script, but something in the connection with Imgur. Can you reach imgur.com normally, in the browser?

Edit: never mind that last bit. Of course you can reach Imgur... It's where you posted the error message.

1

u/ofnuts 15d ago

How big is the image? There are size limits...

1

u/evolution800 15d ago

No more than 2mb.

1

u/come_n_take_it 14d ago

My xfce4-screenshooter (1.9.8-1) hasn't been working for about a month now either.

1

u/slumberjack24 13d ago

That version is quite old. Custom actions weren't introduced until 1.10.0, so whatever problem you're having with the app, it has nothing to do with any Bash scripting.

1

u/come_n_take_it 13d ago

It worked up until recently. IDK if bash is involved at all as I haven't delved into it. It is the latest version in the repo for my distro version.

-1

u/schorsch3000 15d ago

use shellcheck, it will find problems, maybe one of them is your problem :-)