Sponsored Content
Top Forums Shell Programming and Scripting Correlation Between 3 Different Loops using Bash Post 303025961 by Corona688 on Thursday 15th of November 2018 04:13:04 PM
Old 11-15-2018
I think you accidentally posted the same code twice.

Anyway, we have no idea where aws_policy_effects, etc came from, so we cannot possibly say what order they're in.

Also, you can shrink that loop a lot:

Code:
STR=""
for X in "${aws_policy_effects[@]}"
do
        [[ "$X" == "Deny" ]] && STR="$STR DENY" || STR="$STR ALLOW"
done
aws_policy_effects=( $STR ) # Do not quote, splitting is intentional

...but it might have been easier to just pipe the data through tr 'a-z' 'A-Z' in the first place.

I'm sure that last block of code could be shrank too.

Probably all of it could use a good looking over and rewriting.
This User Gave Thanks to Corona688 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

arrays and while loops in bash

hi guys, i have an array called ARRAY which has elements in it... i am trying to assign elements of ARRAY to master_array.. i get a =: command not found error.. i=0 while do ${master_array}=${ARRAY} ((i++)) done is there something i am missing? (4 Replies)
Discussion started by: npatwardhan
4 Replies

2. Shell Programming and Scripting

[bash] IF is eating my loops

Hi! Could someone explain me why the below code is printing the contents of IF block 5 times instead of 0? #!/bin/bash VAR1="something" VAR2="something" for((i=0;i<10;i++)) do if(($VAR1=~$VAR2)) then echo VAR1: $VAR1 echo... (3 Replies)
Discussion started by: machinogodzilla
3 Replies

3. Shell Programming and Scripting

bash scripting: using multiple 'for loops'??

Hey guys, I'm kinda a noob at scripting. I am trying to create a script that uses multiple for loops with the lsiutility to monitor disk health on a system. The script runs, but it will continually echo an infinite number of LogVolumes when there are only 2 per virtual disk on my server. It's... (2 Replies)
Discussion started by: tank126
2 Replies

4. UNIX for Dummies Questions & Answers

A copy paste problem with loops in bash

Hello All, i have a really strange copy paste problem. When I write some loops in an editor for example: for j in 1 2 3 do echo "$j" done and I want to paste it to the shell, the result in the shell is: for j in 1 2 3; do e; other commands work fine and if a copy paste... (4 Replies)
Discussion started by: creamcheese
4 Replies

5. UNIX for Dummies Questions & Answers

Bash loops and variable scope

Hi All, I've been researching this problem and I am pretty sure that the issue is related to the while loop and the piping. There are plenty of other threads about this issue that recommend removing the pipe and using redirection. However, I haven't been able to get it working using the ssh and... (1 Reply)
Discussion started by: 1skydive
1 Replies

6. Homework & Coursework Questions

Bash if and loops help

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Your shell script should continue to execute until the user selects option 4 2. Relevant commands, code,... (2 Replies)
Discussion started by: boyboy1212
2 Replies

7. Shell Programming and Scripting

while loops and variables under bash

Hi, This is probably going to be very simple but i came across something i can't quite explain. Here is the situation: i have a list of files, which i'd like to process one by one (get the size, make some tests, whatever) and generate some statistics using different variables. Something... (5 Replies)
Discussion started by: m69w
5 Replies

8. Shell Programming and Scripting

bash loops

hello i'm writing a script and I want to use a for loop inside a while loop as following: while read line; do echo $line for i in $vrm; do echo $i done done < './contacts' when i use just the while loop it prints the lines from file ./contacts just... (13 Replies)
Discussion started by: vlm
13 Replies

9. Shell Programming and Scripting

Pipe 2 bash loops together

What is the proper way to run two bash loops in the same command? The two below loops run separately, the problem is when I pipe them I get an error that the file used for the second loop does not exist. I am not sure how to wait for the first loop to complete and then start the second. Thank... (10 Replies)
Discussion started by: cmccabe
10 Replies

10. Shell Programming and Scripting

Bash: How to use read with conditions & loops

Hello, Below I try to control that the input is good an IP : #!/bin/bash cp /home/scripts/choice_interfaces.txt /home/scripts/interfaces.txt chmod 644 /home/scripts/interfaces.txt echo -e "Please enter the network informations into the /etc/network/interfaces file, complete them below... (9 Replies)
Discussion started by: Arnaudh78
9 Replies
Amazon::SQS::Simple::Queue(3pm) 			User Contributed Perl Documentation			   Amazon::SQS::Simple::Queue(3pm)

NAME
Amazon::SQS::Simple::Queue - OO API for representing queues from the Amazon Simple Queue Service. SYNOPSIS
use Amazon::SQS::Simple; my $access_key = 'foo'; # Your AWS Access Key ID my $secret_key = 'bar'; # Your AWS Secret Key my $sqs = new Amazon::SQS::Simple($access_key, $secret_key); my $q = $sqs->CreateQueue('queue_name'); $q->SendMessage('Hello world!'); my $msg = $q->ReceiveMessage(); print $msg->MessageBody() # Hello world! $q->DeleteMessage($msg->MessageId()); INTRODUCTION
Don't instantiate this class directly. Objects of this class are returned by various methods in "Amazon::SQS::Simple". See Amazon::SQS::Simple for more details. METHODS
Endpoint() Get the endpoint for the queue. Delete([%opts]) Deletes the queue. Any messages contained in the queue will be lost. SendMessage($message, [%opts]) Sends the message. The message can be up to 8KB in size and should be plain text. ReceiveMessage([%opts]) Get the next message from the queue. Returns an "Amazon::SQS::Simple::Message" object. See Amazon::SQS::Simple::Message for more details. If MaxNumberOfMessages is greater than 1, the method returns an array of "Amazon::SQS::Simple::Message" objects. Options for ReceiveMessage: o MaxNumberOfMessages => NUMBER Maximum number of messages to return. Value should be an integer between 1 and 10 inclusive. Default is 1. DeleteMessage($receipt_handle, [%opts]) Delete the message with the specified receipt handle from the queue ChangeMessageVisibility($receipt_handle, $timeout, [%opts]) NOT SUPPORTED IN APIs EARLIER THAN 2009-01-01 Changes the visibility of the message with the specified receipt handle to $timeout seconds. $timeout must be in the range 0..43200. AddPermission($label, $account_actions, [%opts]) NOT SUPPORTED IN APIs EARLIER THAN 2009-01-01 Sets a permissions policy with the specified label. $account_actions is a reference to a hash mapping 12-digit AWS account numbers to the action(s) you want to permit for those account IDs. The hash value for each key can be a string (e.g. "ReceiveMessage") or a reference to an array of strings (e.g. ["ReceiveMessage", "DeleteMessage"]) RemovePermission($label, [%opts]) NOT SUPPORTED IN APIs EARLIER THAN 2009-01-01 Removes the permissions policy with the specified label. GetAttributes([%opts]) Get the attributes for the queue. Returns a reference to a hash mapping attribute names to their values. Currently the following attribute names are returned: o VisibilityTimeout o ApproximateNumberOfMessages SetAttribute($attribute_name, $attribute_value, [%opts]) Sets the value for a queue attribute. Currently the only valid attribute name is "VisibilityTimeout". AUTHOR
Copyright 2007-2008 Simon Whitaker <swhitaker@cpan.org> This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2009-05-16 Amazon::SQS::Simple::Queue(3pm)
All times are GMT -4. The time now is 01:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy