wget & curl output "No such file or directory"
Asked Answered
A

3

5
wget https://some.url/with/a/file.txt

Returns No such file or directory despite file.txt being present at the location (can be downloaded via browser). Also the directory to save to is writeable by the user running the command.

Aldenalder answered 8/7, 2020 at 0:8 Comment(2)
StackOverflow is dedicated to helping solve programming code problems. Your Q may be more appropriate for Super User , but read their help section regarding on-topic questions . AND please read Help On-topic and Help How-to-ask before posting more Qs here. Good luck.Zippora
Does this answer your question? Are shell scripts sensitive to encoding and line endings?Publish
A
25

There are a lot of related threads but nothing helped.

Finally found out there is an illegal character in front of the url!

That was so hard to find I post it here in case anyone stumbles upon the same.

Aldenalder answered 8/7, 2020 at 0:8 Comment(4)
Care to elaborate? What was the illegal character?Mil
Sorry I only remember it wasn't "visible" so I think it must have been U+FEFF or one of these: U+200B, U+200C, U+200D, U+200E,U+200F.Aldenalder
This happened to me copying the curl command from another application to the terminal. At the terminal prompt I had to delete the spaces and re-insert them for it to work. Thank you for the suggestion.Strife
Just ran into this trying to install lgpio...cut and paste from their website example (even though it looked like it was in a code box). Delete the space between wget and the URL and replace...boom works fine. Took me too long to find this solution, so thank you Steros 3 years later.Outcurve
D
1

Close the terminal and try again to run the script.

Defunct answered 19/9, 2022 at 8:55 Comment(1)
I don't know what was wrong in my session, but re-opening new session and executing same command (it was from history, so it's the same) worked.Husk
W
1

Stumbled upon this with a similar issue using curl. The root cause for me was curl was unable to find the destination directory.

adding --create-dirs to the command will ask curl to create the directories if they do not exist, which solved my issue.

eg.

# I want to download this file to ~/development/csvs/saved_file.csv
# Assume I am executing from a ~/development/ directory, which has no csv dir

# this will not work
curl 'https://bla.com/cool_csv.csv' > csvs/saved_file.csv

# this will work
curl 'https://bla.com/cool_csv.csv' -o csvs/saved_file.csv --create-dirs

-o will replace > and will specify output

reference question

Widdershins answered 1/5, 2023 at 5:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.