It is currently Fri Apr 20, 2018 6:45 am

simple imgur upload script not working for dummy

All times are UTC - 6 hours

Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Mar 09, 2012 12:45 pm   

Joined: Fri Mar 09, 2012 12:10 pm
Posts: 1
Hi, I frequently have several jpg images I need to up at the same time and drop the URLs into mi.txt
The main problem is that I can't figure out where the curl command is failing or why imgur isn't responding with a URL (I've tried several keys which I'm sure work)

Secondary issue is that I'm sure there is a more elegant way than listing 1.jpg 2.jpg and just having it upload *.jpg from that folder.
Additionally, there is probably a limit to the number of images that can be sequentially uploaded too but I don't know what that number is. Couldn't find it on imgur documentation.

set -x
function imgur
        for FILE in "[email protected]"
                curl -F "[email protected]" -F "key=<sensored>" < "$FILE" | grep -Eo "<original>(.)*</original>" | grep -Eo "[^<]*"

imgur 1.jpg 2.jpg 3.jpg #>> mi.txt

any assistance would be much appreciated!

 PostPosted: Fri Mar 09, 2012 2:23 pm   
User avatar

Joined: Wed May 03, 2006 2:05 pm
Posts: 273
Howdy anystupidassname!

From what I can tell, your curl command is good. It's uploading the files, right? It works in my testing for sure.
I think the problem is in your grep commands. Try running it without the greps, and storing the output in a file. From there, you can play with different ways of parsing the output without trying an actual upload every time.

- In my output, the 'original' url is in an "<original_image>" tag, as opposed to the "<original> that you used in your script.
- The parenthesis around the dot are not necessary, and may also be part of the problem

Try this, in place of the two greps:
grep -Eo "<orig[^<]*" | sed 's/<.*>//g'

As for your second question, in my test I simply replaced 1, 2, and 3.jpg with *.jpg
This should work on every .jpg in the current working directory.

I hope this helps!

 Profile YIM  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours

Who is online

Users browsing this forum: No registered users and 21 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  

BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group