A message for Linux.com registered users: We are in the process of making changes to the Linux forums. Starting Monday, 8/13/18 at 6:00 PM PT, you will be unable to access the forums. They will re-launch as soon as possible on Wednesday, 8/15/18 with new features and improved functionality. Thank you for your patience and stay tuned for the new improved forums.

March 8, 2018

POC on connecting to aws iam using awscreds using bash script


<p>All -&nbsp;</p>

<p>Im good at linux but not at expect/send :</p>

<p>below is the function i have written for trying to connect to respective iam role.</p>


<p><br />
function passingvalues {</p>

<p>expect &lt;&lt; EOF<br />
spawn $AWS_USERNAME -c "exit"<br />
expect "password:"<br />
send "$AWS_PASSWORD\r"<br />
expect "role:"<br />
puts "$expect_out(buffer)"<br />
foreach line [split $expect_out(buffer) "\n"] {&nbsp;&nbsp;<br />
&nbsp; &nbsp; &nbsp;if {[regexp -nocase "arn:aws:iam::54250:role/OM-NonProd_RedshiftServices-DevUsers-Team-Support" $line]} {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; puts $line<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
expect eof<br />
EOF<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;}&nbsp;</p>

<p>error : it is unable to iterate through the list of roles displayed and unable to connect.</p>

<p>Can you please help me understand how to grep on a specific value using expect/send.</p>


Click Here!