LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 01-15-2012, 08:51 AM   #1
bobbera
Member
 
Registered: Jun 2007
Posts: 39

Rep: Reputation: 0
How to send sms using wget or curl ?


I'm trying to send sms using this command :

wget -O- "http://user:PASSWORD@sms-server-name/smsmessaging/smsmessage.asmx/Send?loginName=my-domain-name%user-tosend-message&message=test "

And get 401 error:

Connecting to xxxx|10.63.3.8|:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized

Any ideas how to pass user's credentials ?
Should .netrc be involved ?
Curl as alternate ?

/Vlad .
 
Old 01-15-2012, 09:45 AM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
You can try the --user and --password options of wget and remove the credentials from the URL. Moreover you may want the --post-data option to pass the stuff after the ? sign.
 
Old 01-15-2012, 10:14 AM   #3
bobbera
Member
 
Registered: Jun 2007
Posts: 39

Original Poster
Rep: Reputation: 0
The point is that web werver is IIS host and requires user's credentials would be passed .

I switched to that scenario :


wget -O- "http://xxxxx/smsmessaging/smsmessage.asmx/Send?loginName=user-to-send-message&message=test " --post-data user=domain-name\helpdesk&password=xxxxx

Resolving xxxxx... 10.63.3.8
Connecting to ilapp3|10.63.3.8|:80... connected.
HTTP request sent, awaiting response... 401 Unauthorized
Authorization failed.
 
Old 01-15-2012, 10:24 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
What is the output of wget --verbose etc. etc?
 
Old 01-15-2012, 10:37 AM   #5
bobbera
Member
 
Registered: Jun 2007
Posts: 39

Original Poster
Rep: Reputation: 0
--verbose didn't help a lot
I used strace log file and it was more informative :

write(2, "Connecting to xxxxx|10.63.3.8|:"..., 38) = 38
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
connect(3, {sa_family=AF_INET, sin_port=htons(80), sin_addr=inet_addr("10.63.3.8")}, 16) = 0
write(2, "connected.\n", 11) = 11
select(4, NULL, [3], NULL, {900, 0}) = 1 (out [3], left {899, 999997})
write(3, "POST /smsmessaging/smsmessage.as"..., 242) = 242
select(4, NULL, [3], NULL, {900, 0}) = 1 (out [3], left {899, 999998})
write(3, "user=domain-namehelpdesk", 19) = 19
write(2, "HTTP request sent, awaiting resp"..., 40) = 40
select(4, [3], NULL, NULL, {900, 0}) = 1 (in [3], left {899, 999633})
recvfrom(3, "HTTP/1.1 401 Unauthorized\r\nConte"..., 511, MSG_PEEK, NULL, NULL) = 511
read(3, "HTTP/1.1 401 Unauthorized\r\nConte"..., 240) = 240
write(2, "401 Unauthorized\n", 17) = 17
select(4, [3], NULL, NULL, {900, 0}) = 1 (in [3], left {899, 999998})
read(3, "<!DOCTYPE HTML PUBLIC \"-//W3C//D"..., 512) = 512
select(4, [3], NULL, NULL, {900, 0}) = 1 (in [3], left {899, 999999})
read(3, "authorized to view this page</h1"..., 512) = 512
select(4, [3], NULL, NULL, {900, 0}) = 1 (in [3], left {899, 999999})
read(3, "entials.</li>\r\n</ul>\r\n<h2>HTTP E"..., 512) = 512
select(4, [3], NULL, NULL, {900, 0}) = 1 (in [3], left {899, 999999})
read(3, "ty</b>, <b>Authentication</b>, a"..., 120) = 120
write(2, "Authorization failed.\n", 22) = 22

The user - helpdesk was passed as domain-nameusername as one string !
 
Old 01-15-2012, 11:14 AM   #6
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
Actually the verbose output of wget could tell us if the credentials are negotiated and (hopefully) the type of negotiation. The IIS server might be protected by NTLM or GSS.
curl has more explicit options than wget in order to use different authentication methods, e.g. from the curl manual:
Code:
--ntlm (HTTP) Enables NTLM authentication. The NTLM authentication method
       was designed by Microsoft and is used by IIS web servers.
       <omitted>
       This option requires a library built with SSL support. Use
       -V/--version to see if your curl supports NTLM.

--negotiate
       (HTTP) Enables GSS-Negotiate authentication. The GSS-Negotiate method
       was designed by Microsoft and is used in their web applications. It
       is primarily meant as a support for Kerberos5 authentication but may
       be also used along with another authentication method.
       <omitted>
       This  option requires a library built with GSSAPI support. This is
       not very common. Use -V/--version to see if your version supports
       GSS-Negotiate.
Hope this helps.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cURL: Server has many IPs, how would I make a cURL script use those IPs to send data? guest Programming 0 04-11-2009 11:42 AM
How to send sms with sms-pl ? frenchn00b Linux - Software 0 10-01-2007 02:10 PM
wget/curl problems PLS HELP tommmmmm Linux - Software 0 08-19-2005 03:58 AM
YOU for SUSE 9.1 - curl or wget? djc SUSE / openSUSE 1 02-15-2005 03:26 PM
Wget and cURL can't connect umberleigh Linux - Newbie 0 09-21-2004 05:59 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 10:14 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