Passing 2+ parameters to one command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing 2+ parameters to one command
# 1  
Old 07-08-2013
Passing 2+ parameters to one command

I have a script that uses more than one parameter. It looks like this:

Code:
for i in `cat /tmp/listofpolicies`;
do
for x in $(cat /tmp/lst |sed 's/^/\/usr\/openv\/netbackup\/db\/class\//g');
do /usr/openv/netbackup/bin/admincmd/bpplinclude $i -delete -f $x;done;done


The problem is that the file /tmp/listofpolicies contains:
Code:
CORP-GOLD-NETAPP_CH1-NDMP
CORP-GOLD-NETAPP_CH10-NDMP
CORP-GOLD-NETAPP_CH11-NDMP
CORP-GOLD-NETAPP_CH12-NDMP
CORP-GOLD-NETAPP_CH2-NDMP
CORP-GOLD-NETAPP_CH3-NDMP
CORP-GOLD-NETAPP_CH4-NDMP

and the /tmp/lst contains:

Code:
CORP-GOLD-NETAPP_CH1-NDMP/includes
CORP-GOLD-NETAPP_CH10-NDMP/includes
CORP-GOLD-NETAPP_CH11-NDMP/includes
CORP-GOLD-NETAPP_CH12-NDMP/includes
CORP-GOLD-NETAPP_CH2-NDMP/includes
CORP-GOLD-NETAPP_CH3-NDMP/includes
CORP-GOLD-NETAPP_CH4-NDMP/includes

Then when I try to run it I get the proper output from the /tmp/lst but if you notice the value on the /tmp/listofpolicies remains CH1-NDMP when I want it to cycle through the list:

Code:
for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH1-NDMP/includes
file open failed
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CHI10-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH11-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH12-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH2-NDMP/includes
+ for x in '$(cat /tmp/lst |sed '\''s/^/\/usr\/openv\/netbackup\/db\/class\//g'\'')'
+ /usr/openv/netbackup/bin/admincmd/bpplinclude CORP-GOLD-NETAPP_CH1-NDMP -delete -f /usr/openv/netbackup/db/class/CORP-GOLD-NETAPP_CH3-NDMP/includes

Can someone tell me how I should enable this command to cycle through both lists instead of the $i list (/tmp/listofpolicies) always being the same value, CH1?

Any help would be greatly appreciated.

Last edited by Scrutinizer; 07-08-2013 at 02:42 PM.. Reason: more code tags (for the data files)
# 2  
Old 07-08-2013
How about using paste?
Code:
paste /tmp/listofpolicies /tmp/lst | while read i x
do
   ...
done

This User Gave Thanks to Yoda For This Post:
# 3  
Old 07-08-2013
Try:
Code:
netbckbase=/usr/openv/netbackup
while read i && read x<&3
do
  "$netbckbase/bin/admincmd/bpplinclude" "$i" -delete -f "$netbckbase/db/class$x"
done < /tmp/listofpolicies 3</tmp/lst

This User Gave Thanks to Scrutinizer For This Post:
# 4  
Old 07-08-2013
Wow you really are a Jedi!

Yoda:

I never new of the paste command! This is simple and wonderful. The script completed without error! Amazing! Thanks! I will study that man page.
Didn't look at Scrutinizer's post yet, but am sure it is useful too!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing command line parameters into script

Not a good post. (1 Reply)
Discussion started by: bash_in_my_head
1 Replies

2. Shell Programming and Scripting

Automate the passing of parameters

I am writing a script that should read the csv file and pass the values in the file as parameters to the script. The csv file looks like this: TEST_1,20110221 TEST_2,20110220 TEST_3,20110218,20110219 Currently this is how i am running the script ./test.sh <param1> <date> Ex: ./test.sh... (6 Replies)
Discussion started by: stunnerz_84
6 Replies

3. Shell Programming and Scripting

passing parameters using awk

Hi, The below script is working fine awk1.sh ======= awk BEGIN { FS="|" } FNR==NR { f1=$2; next } $1 in f1 && $2 =="xx" && $1 == "DAILY_JOB" {print $3} awk -f awk1.sh a.txt b.txt--Its working fine . When passing parameters its not working .Any help it should be appereciated. ... (4 Replies)
Discussion started by: akil
4 Replies

4. Shell Programming and Scripting

Passing parameters to Shell script for GREP command

I am using grep to capture date from a file . Since i need to use the shell script for different dates ,is it possible to pass the date parameter to the shell script the Script is as below grep -E "08 Aug 2008|2008-08-08"* somefile.txt>test.txt The above script file greps the... (1 Reply)
Discussion started by: sud.tech
1 Replies

5. Shell Programming and Scripting

Passing SSH Command Parameters

Hi, I wan to pass arguments to remote script in Unix . For that I'm using ssh PFB the code I'm using: ssh -t -l osdac 10.81.33.51 "cd /appl/OSD/LOGS/flstr010/test.sh "$1" "$2"" Problem is I'm not able to pass second argument . Can anyone plz help me in resolving this. (5 Replies)
Discussion started by: suchitasaner27
5 Replies

6. Shell Programming and Scripting

passing more than 9 parameters

hi, i am passing around 14 parameters for a script a=$1 b=$2 c=$3 d=$4 e=$5 f=$6 g=$7 h=$8 i=\"${9}\" shift j=\"${1}\" still for j it is displaying the 1st parameter value..how to make it take the 10th parameter (2 Replies)
Discussion started by: dnat
2 Replies

7. Solaris

Passing SSH Command Parameters

On Solaris 5.9, is there any way to pass parameter(s), via SSH, to a command defined in the remote host's authorized_keys file? We have a menu that uses SSH to control some apps on our various hosts. I've been tasked with enhancing it and making it more secure. So far, the local host menu... (2 Replies)
Discussion started by: PabloCruise77
2 Replies

8. Shell Programming and Scripting

Passing parameters through a file

I have created a script "myscript.sh" I need to run this script with diffrent parameters. The parameters are stored in a file myparam.txt. I need to run myscript.sh script for every parameter supplied in myparam.txt. Example: If myparam.txt contains following lines: param1 param2 param3... (3 Replies)
Discussion started by: chawlaaman
3 Replies

9. Shell Programming and Scripting

passing command line parameters to functions - sh

All, I have a sh script of the following tune: function a () { #functionality.. } function b () { #functionnlity.. } function check () { # this function checks for env and if all fine call build } function usage () { #sh usage details } function build () { #calls either a or b or... (5 Replies)
Discussion started by: vino
5 Replies

10. UNIX for Dummies Questions & Answers

passing parameters to sleep command

Hi, Can any one help me with an example how to use Sleep command with parameters thanx, (1 Reply)
Discussion started by: nagaraju_svs
1 Replies
Login or Register to Ask a Question