How to upload all the files from local to host using Curl?

20,949

I would change you script like so:

#!/bin/sh

for file in /folder/path/*
do
  curl -u username:password -T ${file} http://www.example.com/folder/${file}
done

Note that the for-loop variable file is used with curl.

Better way is to upload using find + curl (as was answered on SO):

find /folder/path/ -name '*' -type f -exec curl -u USERNAME:PASSWORD -T {} http://www.example.com/folder/ \;

P.S. More info about

some issue is stopping the files getting uploaded

would be helpful.

Share:
20,949

Related videos on Youtube

thamizhinian
Author by

thamizhinian

Updated on September 18, 2022

Comments

  • thamizhinian
    thamizhinian over 1 year

    i have written a shell script to upload all files with different names in the specific path from local to host, but i have facing some issue and the files are not getting uploaded

    #!/bin/sh
    for file in /main/folder1/path/*
    do
    curl -u Pass:"Uname" -T  $file http://www.example.com/folder/$file
    done
    

    please help me to solve this.

    i am getting the error as following

    <html>
    <head>
    <title> 500 Internal Server Error </title>
    </head>
    <body>
    <h1> 
    Internal Server Error 
    </h1> 
    </body>
    </html>
    

    currently i am having the script inside /main/folder_2, if i change /main/folder_1/path/* to ../folder_1/path/*, i got the output, the files are moved as expected. but i want to run the script with the complete path specified.

  • thamizhinian
    thamizhinian almost 9 years
    hi dude, thanks for the help, this one worked perfectly.
  • DIG mbl
    DIG mbl almost 9 years
    I'm glad it helped.