LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-09-2016, 07:38 PM   #1
dumblinuxuser
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Rep: Reputation: Disabled
cURL command clarification


Hello All,

Can you please help me understand what does cURL -D- command does. My knowledge around curl is pretty basic and at work I was provided a curl command that looks like below, I understand most of the options by reading the man page but the minus behind D is what I am unable to understand.
Can somebody explain in plain terms as to what that minus (-) means

curl -k -D- -u <username>:<password> "https://url"

Thanks in advance.
 
Old 08-09-2016, 07:49 PM   #2
Beads
Member
 
Registered: Nov 2004
Location: Washington
Distribution: Mint
Posts: 104

Rep: Reputation: 17
Quote:
Originally Posted by dumblinuxuser View Post
Hello All,

Can you please help me understand what does cURL -D- command does. My knowledge around curl is pretty basic and at work I was provided a curl command that looks like below, I understand most of the options by reading the man page but the minus behind D is what I am unable to understand.
Can somebody explain in plain terms as to what that minus (-) means

curl -k -D- -u <username>:<password> "https://url"

Thanks in advance.
Hello! The -D option means "Dump Header". Here is the official explanation:

Write the protocol headers to the specified file.

This option is handy to use when you want to store the cookies that a HTTP site sends to you. The cookies could then be read in a second curl invoke by using the -b/--cookie option!

When used on FTP, the ftp server response lines are considered being "headers" and thus are saved there.

If this option is used several times, the last one will be used.
 
1 members found this post helpful.
Old 08-09-2016, 08:01 PM   #3
dumblinuxuser
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thank you Beads. The man page did tell me about the -D option, can you tell me what does the (-) on the right side mean "-D-" is there a significance for that "-" coz, when I remove it the cURL command is failing with error

curl: (6) Couldn't resolve host 'username:<passowrd>'
so i am thinking the that minus (-) on right side is somehow contributing to the -u option to be read correctly.

Last edited by dumblinuxuser; 08-09-2016 at 08:04 PM.
 
Old 08-09-2016, 09:09 PM   #4
AwesomeMachine
LQ Guru
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian testing/sid; OpenSuSE; Fedora; Mint
Posts: 5,524

Rep: Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015Reputation: 1015
I think it's a typo.
 
Old 08-09-2016, 09:28 PM   #5
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
From the bash man page:
Quote:
--
A -- signals the end of options and disables further option processing. Any arguments after the -- are treated as filenames and arguments. An argument of - is equivalent to --.
Try your command this way:
Code:
curl -k -u <username>:<password> "https://url" -D
 
Old 08-09-2016, 09:33 PM   #6
CDR255
LQ Newbie
 
Registered: Dec 2010
Location: New Jersey
Distribution: Slackware 14.2
Posts: 2

Rep: Reputation: 1
The `-D` option to curl takes a filename as an argument.

That is, You need to type `curl -D <file>` for it to store the header in the <file>.

In *nix OSes, the `-` character is a special case. When used in place of a file, it tells the program to write to the standard output (STDOUT).

Typing `curl -D-` is telling curl to write the headers to the standard output.

Removing the `-` in your example makes curl think You want to save the headers in a file named `-u`. This makes curl think You are trying to visit the url <username> at the port <password> (Because you would write it <url>:<port> if that is what you wanted to do.)

There is probably a file in Your present working directory named `-u` that you can safely delete. If you type a filename after the -D option, the error should go away.

Code:
curl -k -D foo -u <username>:<password> "https://url"
(My own assumptions here, obviously. YMMV.)

Last edited by CDR255; 08-09-2016 at 09:42 PM. Reason: Adding in example
 
1 members found this post helpful.
Old 08-09-2016, 09:42 PM   #7
dumblinuxuser
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thank you CDR255, your explanation makes sense. Let me try what you have suggested.
 
  


Reply

Tags
curl, curllibrary



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Queries on Curl command dhanesh.koliyat Linux - Newbie 1 10-11-2011 09:35 AM
using cURL from the command line lauram93 Linux - Software 4 06-05-2009 01:08 PM
Problem in uploading using Curl command. rmvinodh123 Programming 0 05-04-2007 11:36 AM
clarification on find + xargs rm command dtra Linux - General 2 05-17-2006 05:56 AM
Using Curl command backpackingbiker Ubuntu 1 06-21-2005 04:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 06:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration