Shell Imgur upload with curl


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Shell Imgur upload with curl
# 1  
Old 11-14-2011
Shell Imgur upload with curl

Hi

Code:
imgur(){ $*|convert label:@- png:-|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15"
http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>"
| grep -Eo "http://i.imgur.com/[^<]*";}

Execute a command, convert output to .png file, upload file to imgur.com, then returning the address of the .png. | commandlinefu.com.

questions

- howto use this script?
- what does the script exacly? special interested in curl part.
# 2  
Old 11-14-2011
It is a command line function - it goes into your .profile or .bashrc file.

imgur becomes a pseudo-command.
This User Gave Thanks to jim mcnamara For This Post:
# 3  
Old 11-17-2011
doesn't work

Code:
> imgur test.mp4.jpeg 
-bash: test.mp4.jpeg: command not found
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0convert: missing an image filename `png:-' @ error/convert.c/ConvertImageCommand/3016.
100   576    0   258  100   318    216    266  0:00:01  0:00:01 --:--:--   437

Code:
> grep imgur /Users/jonny/.bashrc 
imgur(){ $*|convert label:@- png:-|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*";}

# 4  
Old 11-17-2011
It expects input on standard input, not as a filename, and strangely, seems to run the command instead of just reading data. Perhaps imgur cat filename.jpg
This User Gave Thanks to Corona688 For This Post:
# 5  
Old 11-17-2011
doesn't work - but no error message

Code:
> imgur cat test.mp4.jpeg
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1442    0   634  100   808    188    239  0:00:03  0:00:03 --:--:--   248
http://i.imgur.com/j2MJj.png

but on Imgur there is garbage (not the picture)

Image
# 6  
Old 11-17-2011
download it with wget and run file on it, see what it thinks it is.
This User Gave Thanks to Corona688 For This Post:
# 7  
Old 11-18-2011
Code:
> wget -nd http://i.imgur.com/j2MJj.png
--2011-11-17 22:42:59--  http://i.imgur.com/j2MJj.png
Resolving i.imgur.com (i.imgur.com)... 93.184.221.133
Connecting to i.imgur.com (i.imgur.com)|93.184.221.133|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 489 [image/png]
Saving to: `j2MJj.png'

100%[=========================================================================================================================================================================================>] 489         --.-K/s   in 0s      

2011-11-17 23:12:59 (38.9 MB/s) - `j2MJj.png' saved [489/489]

looks valid

Code:
> file j2MJj.png 
j2MJj.png: PNG image data, 30 x 15, 8-bit grayscale, non-interlaced

very small file 489 Bits

Code:
> ls -al j2MJj.png 
-rw-r--r--  1 jonny  wheel  489 Nov 17 21:45 j2MJj.png
> ls -alh j2MJj.png 
-rw-r--r--  1 jonny  wheel   489B Nov 17 21:45 j2MJj.png

uploaded file

Code:
> ls -alh test.mp4.jpeg 
-rw-r--r--  1 jonny  staff   453K Nov 17 19:16 test.mp4.jpeg
> ls -al test.mp4.jpeg 
-rw-r--r--  1 jonny  staff  463958 Nov 17 19:16 test.mp4.jpeg

---------- Post updated at 04:55 PM ---------- Previous update was at 04:50 PM ----------

I tried with several different image files. But always the same garbage at imgur.com

---------- Post updated 11-18-11 at 11:43 AM ---------- Previous update was 11-17-11 at 04:55 PM ----------

that also doesn't work - no Imgur URL

Code:
 imgur < test.mp4.jpeg 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   576    0   258  100   318    576    710 --:--:-- --:--:-- --:--:--   940

Code:
> grep imgur .bashrc 
imgur(){ $*|curl -F "image=@-" -F "key=1913b4ac473c692372d108209958fd15" http://api.imgur.com/2/upload.xml|grep -Eo "<original>(.)*</original>" | grep -Eo "http://i.imgur.com/[^<]*";}

no other idea?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Curl - upload multiple attachment arrays to server webpage

The html page of the form data is as below <form name="uploadform" id="uploadform" action="htmlupload.php" enctype="multipart/form-data" method="post"> <table class="tborder" cellpadding="6" cellspacing="1" border="0" width="100%" align="center"> <tr> <td class="tcat"> Upload Files ... (0 Replies)
Discussion started by: jaango123
0 Replies

2. Shell Programming and Scripting

FTP in shell script and selecting files for upload

Hi, Im a newbie with programming and shell scripting. Im running OSX/Mac and Darwin. I would like to create a shell script that would : 1. Search a Volume and directory (including subdirectories) for a file that : * filename ends with ”_Highres.pdf” and * the file creation date of... (8 Replies)
Discussion started by: NickeZ28
8 Replies

3. Shell Programming and Scripting

HTML code upload text file grep through shell script

I am looking for HTML code that browse text file and grep with database file then retrieve result txtfileuploaded contain 112233 115599 113366 shell code grep -F -f txtfileuploaded /data/database.txt result 112233 Mar 41$ 115599 Nov 44$ 113366 Oct 33$ attached... (2 Replies)
Discussion started by: phpshell
2 Replies

4. Shell Programming and Scripting

Curl ftp upload success but no file exist on the server !!!!

hello, I'm trying to upload a file to this ftp server and others ftp://ftp.byethost12.com as you can see in the output of CURL using the -v option curl reports that the upload succeeded but when i connected to the server with file-zilla there is no file uploaded the same command upload files... (5 Replies)
Discussion started by: laraaj
5 Replies

5. Shell Programming and Scripting

File upload through curl

hi; I need a script to upload a file using HTTP(curl post) to another system. Will appreciate ur help. Thnks; (0 Replies)
Discussion started by: ajaypadvi
0 Replies

6. Shell Programming and Scripting

Shell Script for Upload/download files using cURL

hi please help me out here, i want to use curl command in shell script to test web pages, what i have is an opening page, when i click on a button on opening page, the next page comes up and then i have to upload a file n then click another button to submit and then comes the output page,... (2 Replies)
Discussion started by: Olivia
2 Replies

7. Shell Programming and Scripting

Shell Script to monitor folder and upload found files via FTP

Hi everyone! I'm in a need of a shell script that search for all files in a folder, move all those files to a temp folder, and upload those files via FTP. When the file transfer via FTP completes successfully, the file is moved to a completed folder. In case any of those files fails, the file... (4 Replies)
Discussion started by: pulsorock
4 Replies

8. Shell Programming and Scripting

ftp put in shell script -- whole file doesn't upload

Hi I'm having some trouble with a bash shell script that I'm writing. In the script, I'm trying to upload a file to a backup repository using ftp, but the whole file doesn't get uploaded. This is the file's properties at the start (I've highlighted the file size in red): -rw-r--r-- 1 root... (2 Replies)
Discussion started by: Viola
2 Replies

9. Shell Programming and Scripting

using curl with shell script.

hi please help me out here, i want to use curl command in shell script to test web pages, what i have is an opening page, when i click on a button on opening page, the next page comes up and then i have to upload a file n then click another button to submit and then comes the output... (0 Replies)
Discussion started by: ankushg002
0 Replies

10. Shell Programming and Scripting

Need Shell Script to upload data from Text file to Oracle database

Hi Does any one have any idea on uploading the data using Unix Shell script from text file to Oracle database. Requirement:- 1. Need to connect to Oracle database from Unix Shell script. 2. Need to pick Text file from some location on Unix Box. 3. Need to upload the data from text file to... (6 Replies)
Discussion started by: chandrashekharj
6 Replies
Login or Register to Ask a Question