0

I have a windows machine, where I have shared a location and made it open through browser using https. Something like this- "https://my-windows/test".

I am writing a shell script which will post a file to this machine/url. I am able to download file using curl from this location but when I post/put, it gives me error. It says that I am trying to put it in a folder and expected is a file.

I don't want to over write an existing file. I want to create a new file. Is this possible with curl? I am writing this shell script in Linux box and destination is a windows box.

I tried following:

1. curl -D- -u user:pass -X POST --data "@test.txt" https://my-windows/test

HTTP/1.1 200 Connection established

HTTP/1.1 405 Method Not Allowed


2. curl -D- -u user:pass -X PUT --data "@test.txt" https://my-windows/test

{
  "errors" : [ {
    "status" : 500,
    "message" : "Expected a file but found a folder
       }
   ]}


3. curl -D- -u user:pass -F "[email protected];filename=nameinpost" https://my-windows/test

HTTP/1.1 200 Connection established

HTTP/1.1 100 Continue

HTTP/1.1 405 Method Not Allowed
Allow: GET,PUT,DELETE
Content-Length: 0
4
  • 1
    what does this do? curl -D- -u user:pass -X PUT --data "@test.txt" https://my-windows/test/test.txt
    – clk
    Commented Apr 5, 2017 at 13:13
  • I am passing my credentials(username and password) and telling that I am using PUT.
    – Raji
    Commented Apr 5, 2017 at 13:35
  • I mean including the file name in the path. https://my-windows/test/test.txt instead of https://my-windows/test.
    – clk
    Commented Apr 5, 2017 at 14:03
  • OhI Sorry, did not read completely. my-windows/test/test.txt instead of my-windows/test works. It created test.txt. Thank you sooo much! I was so stuck with this. Thanks a ton!!!
    – Raji
    Commented Apr 5, 2017 at 14:17

1 Answer 1

0

The error in the second message suggests that you need to include the file name, like this:

curl -D- -u user:pass -X PUT --data "@test.txt" https://my-windows/test/test.txt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .