Sponsored Content
Full Discussion: Need help in loop script
Top Forums Shell Programming and Scripting Need help in loop script Post 302551610 by ranjancom2000 on Wednesday 31st of August 2011 05:09:57 AM
Old 08-31-2011
Need help in loop script

Hi,

This is script i am using currently for create SAN device creating. I need to do some change on this script

Code:
#!/bin/ksh
let x=0
let y=0
let count=$1
let size=$2
for dev in `cat /opt/emc/scripts/bin/noport-devs`
do
        if [[ "$dev" > "$start" ]]
        then
        if [ y -eq $count ]
        then
                exit
        fi
        if [ x -eq 0 ]
        then
                head=$dev 
                echo "form meta from dev $dev config=striped stripe_size=1920;"
        else
                echo "add dev $dev to meta $head;"
                
        fi
        let x=x+1
        if [ x -eq $size ]
        then
                let x=0
                let y=y+1
        fi
        fi

done

Curent output for the above script is

Code:
orm meta from dev 05DF config=striped stripe_size=1920;
add dev 05E1 to meta 05DF;
add dev 0657 to meta 05DF;
add dev 066C to meta 05DF;
form meta from dev 066D config=striped stripe_size=1920;
add dev 09F2 to meta 066D;
add dev 09F3 to meta 066D;
add dev 09F4 to meta 066D;
form meta from dev 09F5 config=striped stripe_size=1920;
add dev 09F6 to meta 09F5;
add dev 09F7 to meta 09F5;
add dev 09F8 to meta 09F5;


I need the oupput to append with this echo

echo "map dev $head to dir 0:0 LUN=00;"
echo "map dev $head to dir 0:0 LUN=00;"


Code:
form meta from dev 05DF config=striped stripe_size=1920;
add dev 05E1 to meta 05DF;
add dev 0657 to meta 05DF;
add dev 066C to meta 05DF;
map dev 05DF to dir 0:0 LUN=00;
map dev 05DF to dir 0:0 LUN=00;
form meta from dev 066D config=striped stripe_size=1920;
add dev 09F2 to meta 066D;
add dev 09F3 to meta 066D;
add dev 09F4 to meta 066D;
map dev 066D to dir 0:0 LUN=00;
map dev 066D to dir 0:0 LUN=00;
form meta from dev 09F5 config=striped stripe_size=1920;
add dev 09F6 to meta 09F5;
add dev 09F7 to meta 09F5;
add dev 09F8 to meta 09F5;
map dev 09F5 to dir 0:0 LUN=00;
map dev 09F5 to dir 0:0 LUN=00;


How i can make this work on the above script

Last edited by pludi; 08-31-2011 at 06:54 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

not quite sure how to loop this script!

:D can anyone tell me how to make this script continue after the *) I have been reading C and shell scripting and am confused.. I tried to impliment a while (1) and a continue after the *) but I keep getting end of file error..! also there a few different loops that I am not sure which type to... (3 Replies)
Discussion started by: moxxx68
3 Replies

2. Shell Programming and Scripting

If then else loop in Shell script

Hi Following is the code . When I give input as Bangalore,its dospalying Welcome to Hitech City. But say , if I select Delhi or US, its not displaying the corresponding message. Its still says Welcome to Hitech City. Seems that it not entering in the elif part. Please suggest. #!... (4 Replies)
Discussion started by: pankajkrmishra
4 Replies

3. Shell Programming and Scripting

loop in a script

I want to write a shell script which clones a file, example the name of the file to be cloned is "es" and I want its clone have the name "es1", "es2", "es3", and so on. Then another program called service needs the former clone as input, for example service up /home/es1, service up /home/es2... (4 Replies)
Discussion started by: Puntino
4 Replies

4. Shell Programming and Scripting

While loop in a script

Hi, I have a unix shell script that I use to run the jobs, which internally calls a number of other jobs and outputs a log file. I want to call another shell script in the main script that constantly reads the log file that gets appended and emails the user upon each job completion. for... (5 Replies)
Discussion started by: rudoraj
5 Replies

5. Shell Programming and Scripting

a script with a for loop

Hi Gurus I have to write a script which does something like this /usr/local/gpg2/bin/GPG2 -o arch_696354351_1_23.dbf -d arch_696354351_1_23.dbf.gpg /usr/local/gpg2/bin/GPG2 -o arch_696354351_1_24.dbf -d arch_696354351_1_24.dbf.gpg /usr/local/gpg2/bin/GPG2 -o arch_696354351_1_25.dbf... (8 Replies)
Discussion started by: appsdba.nitin
8 Replies

6. Shell Programming and Scripting

How to loop use while loop in csh script?

Hi all, i got 2 text file. file.txt value.txt i want use C shell script to write out while both of the file got different limit....how i going to write it in 1 while loop? (4 Replies)
Discussion started by: proghack
4 Replies

7. Shell Programming and Scripting

Loop Script?

Hello World I need to create a script to verify ports are open from a new jump off node to access over 200 different servers. I did a little research and put together this code: !/bin/sh exec 4<nodes.dat while read sys <& 4 do # PING TEST echo "$sys" ping $sys 1 # Example of... (1 Reply)
Discussion started by: paris123
1 Replies

8. Shell Programming and Scripting

Use loop in script

Hi All I want to make a script in which i can print prstat command output to a file in regular interval of 1 second I am using below script for the same dat=`date '+%d%m%y'` echo "###########################################################" >>prstat-$dat date >>prstat-$dat prstat 1 1... (3 Replies)
Discussion started by: devesh123
3 Replies

9. Shell Programming and Scripting

Expect script called in loop from Bash Script

Having issues with an expect script. I've been scripting bash, python, etc... for a couple years now, but just started to try and use Expect. Trying to create a script that takes in some arguments, and then for now, just runs a pwd command(for testing, final will be command I pass). Here is... (0 Replies)
Discussion started by: cbo0485
0 Replies

10. UNIX for Dummies Questions & Answers

Loop SCript

Hi, I am newer to UNIX scripting. Here is what I am trying to accomplish: I want to log a timestamp and a row count for a spcific file, out to another file. Below is my script. WhenI run it, it says that line 6 is missing a ']' which I don't see how, and then echos File Does Not Exist... (5 Replies)
Discussion started by: eanolan
5 Replies
SCRIPT-EMAIL(8) 					  System Administration Commands					   SCRIPT-EMAIL(8)

NAME
script-email - Amanda script to send email notifications DESCRIPTION
script-email is an Amanda script implementing the Script API. It should not be run by users directly. It sends a notification email to the addresses specified in the MAILTO property. PROPERTIES
This section lists the properties that control script-email's functionality. See amanda-scripts(7) for information on the Script API, script configuration. MAILTO List of email addresses that will receive an email on command execution. It is a multi-valued property: property "MAILTO" "amanda@domain.com" "sysadmin@domain.com" "amandauser@domain.com" EXAMPLE
In this example, script-email is scheduled to be run before the DLE, on the server. The unqualified email address amanda will be passed to the email system unchanged. The script is then attached to a dumptype, which can then be specified for any DLEs which require notification. define script-tool pre-email { comment "email me before this DLE is backed up" plugin "script-email" execute-on pre-dle-backup execute-where server property "mailto" "amanda" } define dumptype user-tar-email { user-tar script "pre-email" } SEE ALSO
amanda(8), amanda.conf(5), amanda-client.conf(5), amanda-scripts(7) The Amanda Wiki: : http://wiki.zmanda.com/ AUTHORS
Jean-Louis Martineau <martineau@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Dustin J. Mitchell <dustin@zmanda.com> Zmanda, Inc. (http://www.zmanda.com) Amanda 3.3.3 01/10/2013 SCRIPT-EMAIL(8)
All times are GMT -4. The time now is 10:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy