Operating System - HP-UX
1834200 Members
2712 Online
110066 Solutions
New Discussion

A variable is taken as several parameter given to a function.

 
Manuales
Super Advisor

A variable is taken as several parameter given to a function.

Hi .. I have a function, and it looks like follows when is called:

emails_patito="user1@patito.com user2@patito.com user3@patito.com user4@patito.com"
fun_cel_mail_message 2 $SERVER_name 1001 2001 send $www $emails_patito

Question here is :
why i can not send the message to all people?
i mean, only is taken the first of them or the second of them !!!! why!!! i'm putting them between " " ....

the parameter number 7 probably only take the first because exist a space between them , could be that ? what can i change this one to send to all of them ?

thanks, Manuales.
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor

Re: A variable is taken as several parameter given to a function.

Without knowing how the function, fun_cel_mail_message, itself is written it's not possible to know but if the function is addressing your instantiation of ${emails_patitlo} as simply ${7} then then only thing that ${7} is going to contain is "user1@patito.com"

What you can do is store the 1st 6 parameters into variables and then
shift 6
while [[ ${#} -ge 1 ]]
do
mail_something_to ${1}
shift
fi

or if you invoke your function like this:
fun_cel_mail_message 2 $SERVER_name 1001 2001 send ${www} "${emails_patito}"

$7 will now contain the entire list. This is a case of the shell doing exactly what you are telling it to do.


If it ain't broke, I can fix that.