What I need to do is run a command 32 times; each command needs to have the slave and target specified. Some one decided on a goofy naming convention and there are 4 instances of the target on 8 slaves.
Skeleton of the command is:
execute.lng Slave01 Target01-A
execute.lng Slave01 Target01-B
execute.lng Slave01 Target01-C
execute.lng Slave01 Target01-D
execute.lng Slave02 Target02-A
...
execute.lng Slave08 Target08-D
Must've made sense to someone, but to me I would have prefered a nice easy to code sequence.
Psuedo code should be something like:
Code:
foreach instance ( A B C D)
foreach slave ( 1 2 3 4 5 6 7 8 )
do
execute.lng Slave0$slave Target0$slave-$instance
end
But it is Monday and my mind is mushy from head pounding so this of course is not working in ksh or bash...
The beauty of shell scripts is that it looks almost like a pseudo code.
The solution is almost exactly as you described:
Code:
#!/usr/bin/ksh
for mInstance in $(echo "A B C D"); do
for mServer in $(echo "1 2 3 4 5 6 7 8"); do
echo "mInstance <$mInstance> mServer <$mServer>"
done
done
This User Gave Thanks to Shell_Life For This Post:
Well rested eyes are helpful. Key is to see that sequencing all the A,B,C,Ds is easier way to tackle.
This looks pretty good from the echo:
Code:
#!/usr/bin/ksh
for mInstance in $(echo "A B C D"); do
for mServer in $(echo "1 2 3 4 5 6 7 8"); do
echo "excute.lng Slave0$mServer Target0$mServer-$mInstance"
done
done
Now let's see if I can change that to be a real cmd line arg and hope it runs ....
Quote:
Originally Posted by Shell_Life
The beauty of shell scripts is that it looks almost like a pseudo code.
The solution is almost exactly as you described:
Code:
#!/usr/bin/ksh
for mInstance in $(echo "A B C D"); do
for mServer in $(echo "1 2 3 4 5 6 7 8"); do
echo "mInstance <$mInstance> mServer <$mServer>"
done
done
Hi 2 all,
i have had AIX 7.2
:/# /usr/IBMAHS/bin/apachectl -v
Server version: Apache/2.4.12 (Unix)
Server built: May 25 2015 04:58:27
:/#:/# /usr/IBMAHS/bin/apachectl -M
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_worker_module (static)
... (3 Replies)
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
Hi everybody,
I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o
My code:
#!/bin/sh
set -e
set -u
export IFS=
optl="Optl"
LOCSTORCLI="/opt/lsi/storcli/storcli"
($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
dear all,
i got some questions about for/while loop when working on redirect command output to for/while loop.
take one for example :
in for loop :
allfiles=`find /var/log -maxdepth 1 -type f -mtime +5`
index=1
for ((i=0; i<${#allfiles}; i++)); do
echo "$index:${allfiles}"
... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
Hi.
I have a copy-file script (and a move-file script) that I recently tried to make interactive. I tested the former on three files from a text list, and watched to see what would happen. As the cp command was in a while/do/done loop, there was no pause for input: it wrote the file from the... (2 Replies)
Hi,
I have a problem with "for" and "while" loop in "sh".
I have:
#!/bin/sh
for i in $(seq 1 500000); do
echo $i
doneand it's working in sh on my ubuntu, but when I try to run this on unix(I have access to my university's unix) it crash:
syntax error at line 2: `$' unexpected...... (8 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)