On Mon, May 14, 2007 at 09:13:32AM -0700, Bob McGowan wrote: > cga2000 wrote: > >On Fri, May 11, 2007 at 12:33:12PM EDT, Bob McGowan wrote: > > > ><snip> > > > >> 3. in the parent script, where you use your script, change it to be: > >> > >> HTTP_proxy=$(getproxyip) > > > >.. you can take it one tiny step further by using an array: > > > >. child: > > > >cz=($c0 $c1 $c2) /* .. $c4 .. etc. */ > >echo "[EMAIL PROTECTED]" > > > >. parent: > > > >cz=($(child)) /* note added outer parentheses .. */ > > > >$p0="${cz[0]}" > >$p1="${cz[1]}" > >$p2="${cz[1]}" > > > >.. > > > >I think you need a fairly recent version of bash to do this .. Dunno > >about other shells. > > > >Thanks, > >cga > > > > > > Actually, unless you need an array, this is overkill, if the objective > is to get a series of single values in a series of simple variables (p0 > ... p?). > > Assuming these assignments: x=a y=b z=c p=d > > echo "[EMAIL PROTECTED]" # where cz is (a b c d), from cz=($x $y $z $p) > > and > > echo $x $y $z $p > > generate the same results. > > And you can read data into a series of variables using the 'read' built > in command: > > read x y z p > > The only issue being, if you don't have total control on the output of > the command being read, and it generates more than 4 fields, the 4th to > last field all get stuffed into p, so in that case you'd want to do: > > read x y z p rest > > So: > > $ echo a b c d | read x y z p > $ echo $x $y $z $p > a b c d
what about something like set -- 1 2 3 4 5 6 7 for x do echo $x done change 1 2 3 4 5 6 7 for what every number of variables you want ? > > And read has been part of Bourne shells for ages, so there's less of a > backward compatibility problem. > > Bob
signature.asc
Description: Digital signature