Sponsored Content
Top Forums Shell Programming and Scripting Shell Script for Upload/download files using cURL Post 302484693 by Olivia on Sunday 2nd of January 2011 09:15:56 PM
Old 01-02-2011
Thanks a lot!!!!

Quote:
Originally Posted by dufftime
I recently wrote a script to simulate some web transactions recently (not too different than yours), I had good luck following this tip from curl's website (hxxp://curl.haxx.se/docs/httpscripting.html):

If there are 3 clicks, then there are going to be 3 separate curl commands. You should be able to avoid the first "click", because you'll just be uploading the file in step 2, no need to browse to the first page once you figure out the URL of your POST.

I'm making up examples in as I don't know what your actual HTML form looks like. The trick is figuring out the form query variables (order matters!!) and converting that into your curl command-line arguments.

Code:
#/bin/sh
# 1.  Get page - probably not required
curl http://www.mysite.com/mypage.htm

# 2.  Upload file - most likely a multipart form.  the '@' means upload a local file
curl -F "upload_filename=@/full/path/to/local/file.txt" -F "myotherqueryvar=queryvalue" \
-L http://www.mysite.com/upload-page.htm > html_out.htm

# 3.  Parse HTML - you'll basically have to look at the return page
# and see if you can figure out a pattern that will grab the link.
mylink=`grep (insert pattern here that will get your link) html_out.htm`
curl ${mylink}

Not sure if you can just supply the actual website... might be easier to give you the exact commands.

-dufftime
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Getting upload and download speeds with the help of script?How?

How can I get the upload and download speed of my pc, provided that my interface is wlan0? I have though something like: #!/bin/sh ups=something downs=somethingelse echo " Your current up speed is $ups Your current down speed is $downs, but I have no idea how to get them?Are... (5 Replies)
Discussion started by: hakermania
5 Replies

2. 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

3. Shell Programming and Scripting

curl script to download files from Secured HTTPS server?

curl -# -v -d "sendusername=myname&password=mypassword&wheretogo=download.php" -L -o test.zip http://www.ims-dm.com/cgi/securedownload.php?p=HIREFTPM\&prodtype=hire/test.zip * About to connect() to www.ims-dm.com port 80 * Trying 209.61.193.139... connected * Connected to www.ims-dm.com... (1 Reply)
Discussion started by: laknar
1 Replies

4. UNIX for Dummies Questions & Answers

Shell Imgur upload with curl

Hi 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... (10 Replies)
Discussion started by: slashdotweenie
10 Replies

5. UNIX for Advanced & Expert Users

Help with using curl to download files from https

Hi I'm trying to download an xml file from a https server using curl on a Linux machine with Ubuntu 10.4.2 I am able to connect to the remote server with my username and password but the output is only "Virtual user <username> logged in". I am expecting to download the xml file. My output... (4 Replies)
Discussion started by: henryN
4 Replies

6. Shell Programming and Scripting

Curl ftp ssl download files

Hello all, I have been struggling with this issue on and off for a couple of weeks now and I just got it all working, so I wanted to share my findings in case some other poor soul needs to know how. First some background on what I'm doing. I am uploading files to different directories based on... (0 Replies)
Discussion started by: msjkadams
0 Replies

7. UNIX for Dummies Questions & Answers

How to download files matching pattern from FTP using CURL or WGET?

Hi, For an order I requested, the provider has uploaded a tar file in public FTP site which internally has tons of files (compressed) and I need to download files that follows particular pattern which would be few hundreds. Note: The order can't be requested for files that follows the... (7 Replies)
Discussion started by: Amalan
7 Replies

8. 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

9. Shell Programming and Scripting

Curl command to download multiple files with a file prefix

I am using the below curl command to download a single file from client server and it is working as expected curl --ftp-ssl -k -u ${USER}:${PASSWD} ftp://${HOST}:${PORT}/path/to/${FILE} --output ${DEST}/${FILE} let say the client has 3 files hellofile.101, hellofile.102, hellofile.103 and I... (3 Replies)
Discussion started by: r@v!7*7@
3 Replies

10. Shell Programming and Scripting

Curl , download file with user:pass in bash script

Hello, My question is about curl command. (ubuntu14.04) In terminal, I am able to download my mainfile with: curl -u user1:pass1 http://11.22.33.44/******* When I convert it into bash script like this: #!/bin/bash cd /root/scripts computer_ip=11.22.33.44 curl -u $1:$2... (8 Replies)
Discussion started by: baris35
8 Replies
CURLOPT_RESUME_FROM_LARGE(3)				     curl_easy_setopt options				      CURLOPT_RESUME_FROM_LARGE(3)

NAME
CURLOPT_RESUME_FROM_LARGE - set a point to resume transfer from SYNOPSIS
#include <curl/curl.h> CURLcode curl_easy_setopt(CURL *handle, CURLOPT_RESUME_FROM_LARGE, curl_off_t from); DESCRIPTION
Pass a curl_off_t as parameter. It contains the offset in number of bytes that you want the transfer to start from. Set this option to 0 to make the transfer start from the beginning (effectively disabling resume). For FTP, set this option to -1 to make the transfer start from the end of the target file (useful to continue an interrupted upload). When doing uploads with FTP, the resume position is where in the local/source file libcurl should try to resume the upload from and it will then append the source file to the remote target file. DEFAULT
0, not used PROTOCOLS
HTTP, FTP, SFTP, FILE EXAMPLE
CURL *curl = curl_easy_init(); if(curl) { curl_off_t resume_position = GET_IT_SOMEHOW; curl_off_t file_size = GET_IT_SOMEHOW_AS_WELL; curl_easy_setopt(curl, CURLOPT_URL, "ftp://example.com"); /* resuming upload at this position, possibly beyond 2GB */ curl_easy_setopt(curl, CURLOPT_RESUME_FROM_LARGE, resume_position); /* ask for upload */ curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* set total data amount to expect */ curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, file_size); /* Perform the request */ curl_easy_perform(curl); } AVAILABILITY
Added in 7.11.0 RETURN VALUE
Returns CURLE_OK if the option is supported, and CURLE_UNKNOWN_OPTION if not. SEE ALSO
CURLOPT_RESUME_FROM(3), CURLOPT_RANGE(3), CURLOPT_INFILESIZE_LARGE(3), libcurl 7.54.0 February 03, 2016 CURLOPT_RESUME_FROM_LARGE(3)
All times are GMT -4. The time now is 06:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy