What command should I use with curl in terminal if I want to download an image from a website and put it in a certain folder? - command-line

I have seen
curl -o project/folder/image.png -OL example.com/image.png
Would this command work?
Edit: I figured it out

Related

Not able to download artifact from Nexus using curl

I am trying to download an artifact from Nexus Pro 3.37.3-02 using curl but it is not working. I have found below commands which I think working for many other but in my case I am getting repository, maven.groupId, maven.artifactId, maven.baseVersion, maven.extension is not recognized as internal or external command, operable program or batch files.
curl -u usename:password -L -X GET https://MY_NEXUS/service/rest/v1/search/assets/download?sort=version&repository=MY-REPO&maven.groupId=MY_GROUP&maven.artifactId=MY_ARTIFACT_NAME&maven.baseVersion=0.1-SNAPSHOT&maven.extension=zip
I have followed this documentation to make this command.
https://help.sonatype.com/repomanager3/integrations/rest-and-integration-api/search-api
Any help will be appreciated.
Thanks,
In case if anyone else facing the same problem then this is the solution which worked for me.
curl -u token:tokenPassword -L -X GET "https://MY_NEXUS/service/rest/v1/search/assets/download?sort=version&repository=MY-REPO&group=MY_GROUP&name=MY_ARTIFACT_NAME&version=MY_Version&maven.extension=zip" --output My_Artifact.zip

How do I wget a page from archive.org without the directory?

I'm trying to download a webpage from archive.org (ie http://wayback.archive.org/web/20110410223952id_/http://www.goldalert.com/gold-price-hovers-at-1460-as-ecb-hikes-rates-2/ ) with wget. I want to download it in /00001/index.html. How would I go about doing this?
I tried wget -p -k http://wayback.archive.org/web/20110410223952id_/http://www.goldalert.com/gold-price-hovers-at-1460-as-ecb-hikes-rates-2/ -O 00001/index.html but that didn't work. I than cd into the directory and removed the 00001 from the O flag. It didn't work either. I than just removed the -O flag. It worked but I get the whole archive.org directory (ie wayback.archive.org new directory web new diretory etc...) and the filename's not changed :(
What do I do?
Sorry for the obviously noob question.
wget http://wayback.archive.org/web/20110410223952id_/http://www.goldalert.com/gold-price-hovers-at-1460-as-ecb-hikes-rates-2/ -O 00001/index.html
Solve my own question. So simple.

wget -k -p -r exampleserver.com doesn't download images?

Title says it all. I try to download a page with wget -k -p -r and it downloads .html .js and robots.txt only. I need those images as well. They didn't land in my folder. What's wrong? I used same command on another page and it did what i wanted.
Add -H option and it works. -H is for Host
No it does not. It only downloaded a load of crap.

Is is possible to get around zsh autocorrect for one specific argument?

So, I''m testing out something and I have to run the same command repeatedly until it works. I'm doing something like this:
curl -X POST -d #filename.xml https://host.name
When I do that, zsh always replies with
zsh: correct '#filename.xml' to 'filename.xml' [nyae]? y
I want to get zsh to stop trying to autocorrect for only this command with only this argument. I eventually just made an alias in my .zshrc file and that solves the problem for me.
I'm just wondering if there is a better way to do this.
Prefix the word with \ to avoid spelling correction:
curl -X POST -d \#filename.xml https://host.name

How do I deploy a file to Artifactory using the command line?

I've spent far more time on this than I care to admit. I am trying to just deploy one file into my Artifactory server from the command line. I'm doing this using gradle because that is how we manage our java builds. However, this artifact is an NDK/JNI build artifact, and does not use gradle.
So I just need the simplest gradle script to do the deploy. Something equivalent to:
scp <file> <remote>
I am currently trying to use the artifactory plugin, and am having little luck in locating a reference for the plugin.
curl POST did not work for me . PUT worked correctly . The usage is
curl -X PUT $SERVER/$PATH/$FILE --data-binary #localfile
example :
$ curl -v --user username:password --data-binary #local-file -X PUT "http://<artifactory server >/artifactory/abc-snapshot-local/remotepath/remotefile"
Instead of using the curl command, I recommend using the jfrog CLI.
Download from here - https://www.jfrog.com/getcli/ and use the following command (make sure the file is executable) -
./jfrog rt u <file-name> <upload-path>
Here is a simple example:
./jfrog rt u sample-service-1.0.0.jar libs-release-local/com/sample-service/1.0.0/
You will be prompted for credentials and the repo URL the first time.
You can do lots of other stuff with this CLI tool. Check out the detailed instructions here - https://www.jfrog.com/confluence/display/RTF/JFrog+CLI.
The documentation for the artifactory plugin can be found, as expected, in Artifactory User Guide.
Please note that it is adviced to use the newer plugin - artifactory-publish, which supports the new Gradle publishing model.
Regarding uploading from the command line, you really don't need gradle for that. You can execute a simple PUT query using CURL or any other tool.
And of course if you just want to get your file into Artifactory, you can always deploy it via the UI.
Take a look the Artifactory REST API, mostly you can't use scp command, instead use the curl command towards REST API.
$ curl -X POST $SERVER/$PATH/$FILE --data #localfile
Mostly it looks like
$ curl -X POST http://localhost:8081/artifactory/abc-snapshot-local/remotepath/remotefile --data #localfile
The scp command is only used if you really want to access the internal folder which is managed by artifactory
$ curl -v -X PUT \
--user username:password \
--upload-file <path to your file> \
http://localhost:8080/artifactory/libs-release-local/my/jar/1.0/jar-1.0.jar
Ironically, I'm answering my own question. After a couple more hours working on the problem, I found a sample project on github: https://github.com/JFrogDev/project-examples
The project even includes a straightforward bash script for doing the exact deploy/copy from the command line that I was looking for, as well as a couple of less straightforward gradle scripts.
As per official docs, You can upload any file using the following command:
curl -u username:password -T <PATH_TO_FILE> "https://<ARTIFACTORY_SERVER>/<REPOSITORY_PATH>/<TARGET_FILE>"
Note: The user should have write access to this path.