cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: curl: Argument list too long

From: Sergei Steshenko <sergstesh_at_yahoo.com>
Date: Fri, 4 Dec 2009 20:58:07 -0800 (PST)

--- On Fri, 12/4/09, Harry <lolwutaf2_at_gmail.com> wrote:

> From: Harry <lolwutaf2_at_gmail.com>
> Subject: Re: curl: Argument list too long
> To: curl-users_at_cool.haxx.se
> Date: Friday, December 4, 2009, 8:22 AM
> >--- On Thu, 12/3/09, Harry
> <lolwutaf2_at_gmail.com> wrote:
>
> >> From: Harry <lolwutaf2_at_gmail.com>
> >> Subject: curl: Argument list too long
> >> To: curl-users_at_cool.haxx.se
> >>> Date: Thursday, December 3, 2009, 9:23 PM
> >> Hi, I am trying to get cURL to upload
> >> an image scrotted onto a PHP file uploader.
> >>
> >> Here is my code so far, if you can help me, I'd be
> glad.
> >>
> >>
> >>
> >> #!/bin/bash
> >> scrot screenshot.png
> >> curl -v -A "scrotty-v1" "http://harryy.us/upload/index.php" --max-time '60'
> >> --max-filesize '5000000' -F "mailfile=`cat
> screenshot.png`"
> >>
> >> At the moment, I get "curl: Argument list too
> long".
> >>
> >>
> >> Thank you in advance.
> >>
> -------------------------------------------------------------------
> >The
> >
> >"mailfile=`cat screenshot.png`"
> >
> >part looks strange to me. This is because
> >
> >cat screenshot.png
> >
> >is executed, and then its stdout is placed into the
> double quoted string, the whole
> >
> >"mailfile=`cat screenshot.png`"
> >
> >is 'mailfile=' plus contents of 'screenshot.png' file,
> And I think this is
> >what makes your command too line long.
> >
> >OTOH, you command line doesn't make sense to because of
> the above in the first place.
> >
> >Did you mean regular single quotes ("'") and not the
> backquotes ("`") ?
> >
> >Thanks,
> >  Sergei.
>
> Hi, the script is used for uploading an image to a PHP file
> uploader.
> It's intentional to make the contents of the screenshot
> file uploaded, or I would think so.
>
> Unless you suggest a better way to upload the
> screenshot.png onto the server, via that PHP upload form?
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-users
> FAQ:        http://curl.haxx.se/docs/faq.html
> Etiquette:  http://curl.haxx.se/mail/etiquette.html
>

For your convenience here is an excerpt from 'man curl':

"
       -F/--form <name=content>
              (HTTP) This lets curl emulate a filled-in form in which a user has pressed the submit button. This causes curl to POST data using the Content-Type multi-
              part/form-data according to RFC2388. This enables uploading of binary files etc. To force the 'content' part to be a file, prefix the file name with an @
              sign. To just get the content part from a file, prefix the file name with the symbol <. The difference between @ and < is then that @ makes a file get
              attached in the post as a file upload, while the < makes a text field and just get the contents for that text field from a file.

              Example, to send your password file to the server, where 'password' is the name of the form-field to which /etc/passwd will be the input:

              curl -F password=@/etc/passwd www.mypasswords.com

              To read the file's content from stdin instead of a file, use - where the file name should've been. This goes for both @ and < constructs.

              You can also tell curl what Content-Type to use by using 'type=', in a manner similar to:

              curl -F "web=@index.html;type=text/html" url.com

              or

              curl -F "name=daniel;type=text/foo" url.com

              You can also explicitly change the name field of an file upload part by setting filename=, like this:

              curl -F "file=@localfile;filename=nameinpost" url.com

              See further examples and details in the MANUAL.

              This option can be used multiple times.
".

I do not see your actions are based on the excerpt, and, as I wrote in
my reply, your actions lead to a very long command line.

And/or, in simpler English, the examples above nowhere suggest usage of
backquotes.

Regards,
  Sergei.

      
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2009-12-05