Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Script to iterate over several options Post 303032696 by bakunin on Friday 22nd of March 2019 06:34:21 AM
Old 03-22-2019
Although i am sure Corona688s suggestion is working fine for reasons of maintainability and understandability my suggestion is to use arrays for this kind of data. If the number of paramter sets to cycle through increases it is easier to extend this way. Something like this:

Code:
BASE=/opt/SP/
server[1]="server1" ;    user[1]="user1"  ;     dom[1]="dom1"
server[2]="server2" ;    user[2]="user2"  ;     dom[2]="dom2"
server[3]="server3" ;    user[3]="user3"  ;     dom[3]="dom3"

(( i = 1 ))
while [ $i -le ${#server[@]} ] ; do
        ssh -t "${user[$i]}@${server[$i]}" "cd $BASE/${dom[$i]} ; exec bash"
        (( i += 1 ))
done

I hope this helps.

bakunin
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Iterate a min/max awk script over time-series temperature data

I'm trying to iterate a UNIX awk script that returns min/max temperature data for each day from a monthly weather data file (01_weath.dat). The temperature data is held in $5. The temps are reported each minute so each day contains 1440 temperature enteries. The below code has gotten me as far as... (5 Replies)
Discussion started by: jgourley
5 Replies

2. Shell Programming and Scripting

Help with options and arguments to a script

I'm trying to write a script that accepts both arguments and options, e.g. ./script -h 1 -m 15 -s 30 or ./script -h 1 -m 15 -s 30 I'd like for any of the arguments and options to be optional, and the option values should be numerals only. I've tried both getopt and getopts but I... (1 Reply)
Discussion started by: Ilja
1 Replies

3. Shell Programming and Scripting

Passing options into a script

Afternoon all, I have been writing a script to do some selects on a table dependent on what options are selected when the script is run: #!/bin/ksh set -x set -m if then echo "usage: msglog.ksh -da <date and time> -i <interface> -m <msg> -di <direction> -mi <MIR>" exit 1 fi... (3 Replies)
Discussion started by: chris01010
3 Replies

4. UNIX for Dummies Questions & Answers

[solved] Script creation (how to include options in the script)

Hi guys i have written a script which takes the options given to him and execute itself accordingly. for example if a script name is doctortux then executing doctortux without option should made doctortux to be executed in automatic mode i.e. doctortux -a or if a doctortux is needed to run in... (4 Replies)
Discussion started by: pinga123
4 Replies

5. Shell Programming and Scripting

Need script to count specific word and iterate over number of files.

Hi Experts, I want to know the count of specific word in a file. I have almost 600+ files. So I want to loop thru each file and get the count of the specific word. Please help me on achieving this... Many thanks (2 Replies)
Discussion started by: elamurugu
2 Replies

6. Shell Programming and Scripting

shell script options

one thing i was trying to figure out is if you can give people the option to choose what they want to do in a shell script. for example, let's just say that you have a simple shell script to install a couple of programs, can you make it to where you can press a certain key to install a certain... (1 Reply)
Discussion started by: hotshot247
1 Replies

7. Shell Programming and Scripting

script to iterate

Hi i need to find x in the following equation such that it satisfies this condition: y/x-ln(x)-1.24=0 how can i write a script to iterate to give random x to satisfy this equation. y is different each time too. any help with awk/shell script will be awesome! thanks (1 Reply)
Discussion started by: saint2006
1 Replies

8. UNIX for Dummies Questions & Answers

Script to iterate all command line arguments

Hi guys, I am having trouble with this script. What i want it to do is to iterate all command line arguments in reverse order. The code below does this fine but i need the output to print the words on separate lines instead of one line: #!/bin/bash #Takes in the arguments and displays them... (7 Replies)
Discussion started by: pipeline2012
7 Replies

9. Shell Programming and Scripting

Iterate over `dirs` in a bash script

I would like to iterate over `dirs`in a script, but the script will never show more than one (current) folder #! /bin/bash for i in `dirs` do echo ${i} done echo ++++++++++++++++++ for i in $( dirs -p ) do echo ${i} done echo ------------------ dirscontent=`dirs` echo... (5 Replies)
Discussion started by: alexanderb
5 Replies
HTTP::OAI::Repository(3pm)				User Contributed Perl Documentation				HTTP::OAI::Repository(3pm)

NAME
HTTP::OAI::Repository - Documentation for building an OAI compliant repository using OAI-PERL DESCRIPTION
Using the OAI-PERL library in a repository context requires the user to build the OAI responses to be sent to OAI harvesters. SYNOPSIS 1 use HTTP::OAI::Harvester; use HTTP::OAI::Metadata::OAI_DC; use XML::SAX::Writer; use XML::LibXML; # (all of these options _must_ be supplied to comply with the OAI protocol) # (protocolVersion and responseDate both have sensible defaults) my $r = new HTTP::OAI::Identify( baseURL=>'http://yourhost/cgi/oai', adminEmail=>'youremail@yourhost', repositoryName=>'agoodname', requestURL=>self_url() ); # Include a description (an XML::LibXML Dom object) $r->description(new HTTP::OAI::Metadata(dom=>$dom)); my $r = HTTP::OAI::Record->new( header=>HTTP::OAI::Header->new( identifier=>'oai:myrepo:10', datestamp=>'2004-10-01' ), metadata=>HTTP::OAI::Metadata::OAI_DC->new( dc=>{title=>['Hello, World!'],description=>['My Record']} ) ); $r->about(HTTP::OAI::Metadata->new(dom=>$dom)); my $writer = XML::SAX::Writer->new(); $r->set_handler($writer); $r->generate; Building an OAI compliant repository The validation scripts included in this module provide the repository admin with a number of tools for helping with being OAI compliant, however they can not be exhaustive in themselves. METHODS
$r = HTTP::OAI::Repository::validate_request(%paramlist) $r = HTTP::OAI::Repository::validate_request_2_0(%paramlist) These functions, exported by the Repository module, validate an OAI request against the protocol requirements. Returns an HTTP::Response object, with the code set to 200 if the request is well-formed, or an error code and the message set. e.g: my $r = validate_request(%paramlist); print header(-status=>$r->code.' '.$r->message), $r->error_as_HTML; Note that validate_request attempts to be as strict to the Protocol as possible. $b = HTTP::OAI::Repository::validate_date($date) $b = HTTP::OAI::Repository::validate_metadataPrefix($mdp) $b = HTTP::OAI::Repository::validate_responseDate($date) $b = HTTP::OAI::Repository::validate_setSpec($set) These functions, exported by the Repository module, validate the given type of OAI data. Returns true if the given value is sane, false otherwise. EXAMPLE
See the bin/gateway.pl for an example implementation (it's actually for creating a static repository gateway, but you get the idea!). perl v5.12.4 2010-09-01 HTTP::OAI::Repository(3pm)
All times are GMT -4. The time now is 02:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy