Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Fri Aug 21, 2015 7:48 pm 
Offline
Junior Member

Joined: Thu Feb 06, 2014 6:26 pm
Posts: 25
I'm trying to use curl to execute Linode API commands but I haven't been able to figure out how to have curl read my key from a file so that I don't have to enter the key in every command. This command works:

curl -u u:my-linode-key 'https://api.linode.com/?api_action=linode.list&LinodeID=12345' | jsonpp

However this command doesn't work as I would expect (the key is in the linode_key.txt file):

curl -u u:@linode_key.txt 'https://api.linode.com/?api_action=linode.list&LinodeID=12345' | jsonpp

I've read the curl docs but I don't see what I'm doing wrong. Has anyone else managed to do this correctly? Thanks!


Top
   
PostPosted: Fri Aug 21, 2015 7:57 pm 
Offline
Senior Member

Joined: Mon Jul 05, 2010 5:13 pm
Posts: 392
http://manpages.ubuntu.com/manpages/pre ... url.1.html

May want to search that for "password".

- Les


Top
   
PostPosted: Sat Aug 22, 2015 12:21 am 
Offline
Senior Member
User avatar

Joined: Sun Jan 18, 2009 2:41 pm
Posts: 830
You can supply the password via command substitution within the shell like this:
Code:
curl -u u:$(cat linode_key.txt) 'https://api.linode.com/?api_action=linode.list&LinodeID=12345' | jsonpp


Or you may find using the -n option and creating a .netrc file to be more convenient.


Top
   
PostPosted: Sat Aug 22, 2015 1:51 pm 
Offline
Junior Member

Joined: Thu Feb 06, 2014 6:26 pm
Posts: 25
Thanks guys. Your answers were very helpful.


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group