Re: Bash cgi upload form

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



> From: Sean Carolan <scarolan@xxxxxxxxx>

> 
> Anyone have a function or script for uploading files from a web
> browser with a bash script?  I know this is possible to do with Perl,
> I'm wondering if the same is possible using only bash.

I use curl.
It can be a bit tricky if you use POSTDATA...
Here's the function I use:

# upload_file <URL> <POSTDATA> <FILE>
function upload_file() {
  URL="$1"
  DATA="$2"
  FILE="$3"
  PARAMS="-F \"file=@$FILE\""
  IFS="&"
  for PARAM in $DATA
    do
      PARAMS="$PARAMS -F \"$PARAM\""
    done
  IFS=" "
  eval `echo curl $PARAMS $URL 2>/dev/null`
  if [ $? -ne 0 ]; then echo "curl error $?"; fi
}

JD


      

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux