<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>Bash - Cognizant Transmutation</title>
	<atom:link href="https://www.ibd.com/tag/bash/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.ibd.com</link>
	<description>Internet Bandwidth Development: Composting the Internet for over Two Decades</description>
	<lastBuildDate>Thu, 05 Aug 2021 05:25:58 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.1</generator>

<image>
	<url>https://i0.wp.com/www.ibd.com/wp-content/uploads/2019/01/fullsizeoutput_7ae8.jpeg?fit=32%2C32&#038;ssl=1</url>
	<title>Bash - Cognizant Transmutation</title>
	<link>https://www.ibd.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<atom:link rel="hub" href="https://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="https://pubsubhubbub.superfeedr.com"/><atom:link rel="hub" href="https://websubhub.com/hub"/><site xmlns="com-wordpress:feed-additions:1">156814061</site>	<item>
		<title>CLI to Switch Amazon AWS Shell Environment Credentials</title>
		<link>https://www.ibd.com/howto/cli-to-switch-amazon-aws-shell-environment-credentials/</link>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Mon, 16 Jun 2014 04:54:11 +0000</pubDate>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Scalable Deployment]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[AWS]]></category>
		<category><![CDATA[Bash]]></category>
		<category><![CDATA[CLI]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=1616</guid>

					<description><![CDATA[<p>I work with many different AWS IAM Accounts and need to easily switch between these accounts. The good news is the AWS CLI tools now support a standard config file (~/.aws/config) that allows you to create profiles  for  multiple accounts in the one config file. You can select them when using the aws-cli with the --profile flag. But many other&#8230;</p>
<p>The post <a href="https://www.ibd.com/howto/cli-to-switch-amazon-aws-shell-environment-credentials/">CLI to Switch Amazon AWS Shell Environment Credentials</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<p><a href="http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-multiple-profiles" target="_blank" rel="noopener"><img decoding="async" loading="lazy" class="alignleft wp-image-1625 size-full" src="https://i0.wp.com/www.ibd.com/wp-content/uploads/2014/06/AwsCreds.png?resize=300%2C300" alt="AwsCreds" width="300" height="300" data-recalc-dims="1" /></a>I work with many different AWS IAM Accounts and need to easily switch between these accounts. The good news is the AWS CLI tools now support a standard config file (<code>~/.aws/config</code>) that allows you to create profiles  for  multiple accounts in the one config file. You can select them when using the <code>aws-cli</code> with the <code>--profile</code> flag.</p>
<p>But many other tools don&#8217;t yet support the new format config file or multi-profiles. But they do support shell environment variables. So I wrote a simple ruby script that</p>
<ul>
<li>Allows you to specify the profile name as an argument</li>
<li>Reads in the config file ~/.aws/config</li>
<li>Outputs the export statements for publishing the environment variables
<ul>
<li>You can eval the output to set the environment of your current shell session</li>
</ul>
</li>
</ul>
<p>So if you had a config file ~/.aws/config that looked like this:</p>
<pre><pre class="brush: plain; light: false; title: ~/.aws/config; notranslate">
[default]
aws_access_key_id=AKI***********2A
aws_secret_access_key=jt41************************************p
region=us-east-1

[profile foo]
aws_access_key_id=0K***************K82
aws_secret_access_key=2b+***********************************1g
region=us-east-1

[profile bar]
aws_access_key_id=AKI**************GA
aws_secret_access_key=MG************************************/d
region=us-east-1
</pre>
<p>If you don&#8217;t specify any argument to the command it will output the default profile:</p>
<pre><pre class="brush: bash; title: ; notranslate">
 $ aws_switch
export AWS_ACCESS_KEY_ID=AKI***********2A
export AWS_SECRET_ACCESS_KEY=jt41************************************p
export AMAZON_ACCESS_KEY_ID=AKI***********2A
export AMAZON_SECRET_ACCESS_KEY=jt41************************************p
export AWS_ACCESS_KEY=AKI***********2A
export AWS_SECRET_KEY=jt41************************************p
</pre>
<p>If you specified a profile (in this case <code>foo</code>):</p>
<pre><pre class="brush: bash; title: ; notranslate">
$ aws_switch foo
export AWS_ACCESS_KEY_ID=0K***************K82
export AWS_SECRET_ACCESS_KEY=2b+***********************************1g
export AMAZON_ACCESS_KEY_ID=0K***************K82
export AMAZON_SECRET_ACCESS_KEY=2b+***********************************1g
export AWS_ACCESS_KEY=0K***************K82
export AWS_SECRET_KEY=2b+***********************************1g
</pre>
<p>You would actually use it by eval&#8217;ing the output of <code>aws_switch</code> so it sets the variables in the environment of yhour current shell:</p>
<pre><pre class="brush: bash; title: ; notranslate">
eval `aws_switch foo`
</pre>
<p>Here&#8217;s the code for <code>aws_switch</code>. Put it in someplace in your <code>$PATH</code> and make sure to <code>chmod 0755</code> the file so its executable:</p>
<pre><pre class="brush: ruby; light: false; title: aws_switch; notranslate">
#!/usr/bin/env ruby
require 'inifile'

configs = IniFile.load(File.join(File.expand_path('~'), '.aws', 'config'))

profile_name_input = ARGV[0]
case profile_name_input
when 'default'
  profile_name = 'default'
when nil
  profile_name = 'default'
when &quot;&quot;
  profile_name = 'default'
else
  profile_name = &quot;profile #{profile_name_input}&quot;
end

id = configs[profile_name]['aws_access_key_id']
key = configs[profile_name]['aws_secret_access_key']

puts &quot;export AWS_ACCESS_KEY_ID=#{id}&quot;
puts &quot;export AWS_SECRET_ACCESS_KEY=#{key}&quot;
puts &quot;export AMAZON_ACCESS_KEY_ID=#{id}&quot;
puts &quot;export AMAZON_SECRET_ACCESS_KEY=#{key}&quot;
puts &quot;export AWS_ACCESS_KEY=#{id}&quot;
puts &quot;export AWS_SECRET_KEY=#{key}&quot;
</pre><p>The post <a href="https://www.ibd.com/howto/cli-to-switch-amazon-aws-shell-environment-credentials/">CLI to Switch Amazon AWS Shell Environment Credentials</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1616</post-id>	</item>
		<item>
		<title>Install Pgrep and PKill for Mac OS X with Brew</title>
		<link>https://www.ibd.com/macintosh/install-pgrep-and-pkill-for-mac-os-x-with-brew/</link>
		
		<dc:creator><![CDATA[Robert J Berger]]></dc:creator>
		<pubDate>Fri, 29 Jul 2011 05:43:31 +0000</pubDate>
				<category><![CDATA[Macintosh]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[Bash]]></category>
		<guid isPermaLink="false">http://blog2.ibd.com/?p=801</guid>

					<description><![CDATA[<p>My fingers still tend to do ps ax &#124; grep some_program_name_I_want_to_kill and then do a kill 2012 to kill that process. Then I remember that I could use pgrep and/or pkill to do the same kind of thing. But then I remember I&#8217;m on a Mac which doesn&#8217;t have those commands built in, though most other *nix platforms do. So&#8230;</p>
<p>The post <a href="https://www.ibd.com/macintosh/install-pgrep-and-pkill-for-mac-os-x-with-brew/">Install Pgrep and PKill for Mac OS X with Brew</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></description>
										<content:encoded><![CDATA[<p>My fingers still tend to do <code>ps ax | grep some_program_name_I_want_to_kill</code> and then do a <code>kill 2012</code> to kill that process. Then I remember that I could use <a href="http://en.wikipedia.org/wiki/Pgrep" target="_blank">pgrep</a> and/or <a href="http://en.wikipedia.org/wiki/Pkill" target="_blank">pkill</a> to do the same kind of thing. But then I remember I&#8217;m on a Mac which doesn&#8217;t have those commands built in, though most other *nix platforms do.</p>
<p>So I usually would try to use <a href="http://mxcl.github.com/homebrew/" target="_blank">Homebrew</a> to install it: <code>brew install pgrep</code></p>
<p>only to get: <code><span style="color: #ff0000;">Error</span>: No available formula for pgrep</code></p>
<p>After a bit of googling I find again that its: <code>brew install <a href="http://proctools.sourceforge.net/" target="_blank">proctools</a></code></p>
<p>&nbsp;</p><p>The post <a href="https://www.ibd.com/macintosh/install-pgrep-and-pkill-for-mac-os-x-with-brew/">Install Pgrep and PKill for Mac OS X with Brew</a> first appeared on <a href="https://www.ibd.com">Cognizant Transmutation</a>.</p>]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">801</post-id>	</item>
	</channel>
</rss>
