Thanks Rob for your reply. I included the log to clarify. The way I want to
script to run is that:
1) when $vr =2 the $vci and $vpi and the ip address should increment once.
Then when $vr=3 then they should increment once again. In the log the vr
waits till the ip address finishes incrementing and then waits for each
addition variable to increment before incrementing. 


new script:
$telnet->cmd ("up\n");
        for ($vr=2; $vr<=42; $vr++) {
          for ($vci=101; $vci<=141; $vci++) {
          for ($vcp=201; $vcp<=241; $vcp++) {
            for ($ip=1; $ip<=61; $ip++) {
              for ($i=1; $i<=41; $i++) {

        $telnet->cmd ("router provider ipsectest$vr engine 3/2\n");
        $telnet->cmd ("service-domain 1\n");
        $telnet->cmd ("ike secret ip-address 0.0.0.0 secret
springtidenet\n");
        $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 encryption
des\n");
        $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 group 1\n");
        $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 hash sha\n");
        $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 lifetime 12\n");
        $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 lifebytes 0\n");
        $telnet->cmd ("interface internal-atm-pvc 1/$vci 3/2 1/$vcp\n");
        $telnet->cmd ("ip address 10.$ip.$ip.2 netmask 255.255.255.0\n");
        $telnet->cmd ("up\n");
        $telnet->cmd ("up\n");
        $telnet->cmd ("virtual-interface tunnel IPSEC$i policy-name
policy7\n");
        $telnet->cmd ("ip unnumbered\n");
        $telnet->cmd ("up\n");
        $telnet->cmd ("up\n");
        $telnet->cmd ("up\n");
        }
        }
        }
        }
        }



Log:

08/26/2002 00:35:13 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.54.54.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101
3/2 1/101 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.53.53.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101
3/2 1/101 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.52.52.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:13 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101
3/2 1/101 , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter)# up , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter-If)# up , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter-If-logIf)# ip address
10.51.51.1 netma
sk 255.255.255.0 , Status=Passed
08/26/2002 00:35:12 admin/1 Support47(config-vrouter-If)# interface
internal-atm-pvc 1/101

-----Original Message-----
From: Hanson, Rob [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 23, 2002 5:05 PM
To: 'Winchester, Derek S (Derek)'; [EMAIL PROTECTED]
Subject: RE: looping issue


I'm not exactly sure what you are doing, so all I can do is give some tips.

First of all, you probably want to use for(), and not foreach().  for()
takes 3 arguments... an initialization, a expression to test, and an
incrementor.  So your loop might look like this...

for ($vr=2; $vr<=42; $vr++) {
  for ($vci=101; $vci<=141; $vci++) {
    for ($ip=1; $ip<=61; $ip++) {
      for ($i=1; $i<=41; $i++) {
      }
    }
  }
}

You can then increment any of the values inside of the loop in needed.  Like
this...

# prints "12346789", skips "5"
for ($x=1; $x<=9; $x++) {
   $x++ if ($x == 5);
   print $x;
}

Hope that helps.

Rob


-----Original Message-----
From: Winchester, Derek S (Derek) [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 23, 2002 4:52 PM
To: [EMAIL PROTECTED]
Subject: looping issue


This is just an example of what I am trying to do. Only I don't know any
other format in which to do it and when I look in documentation it is
confusing. I have always used foreach, but in this case I don't want to loop
in my loop. For example, below if if the variable on ipsectest$vr equals 2
then I want the rest of the variables to increment when the first variable
increments to perform just one loop. I cant find a way to do such. And I
think Perl doc is just as confusing. If you understand could someone show me
a way of doing what I have described. 
 
 
$vr = 2; 
 $vci = 101; 
 $ip = 1; 
 $vti = 1; 
 
 foreach $vr (2..42) {
 foreach $vci (101..141)  { 
 foreach $ip (1..61) {
 foreach $1 (1..41) {
  
 $telnet->cmd ("router provider ipsectest$vr engine 3/2\n");
 $telnet->cmd ("service-domain 1\n");
 $telnet->cmd ("ike secret ip-address 0.0.0.0 secret springtidenet\n");
 $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 encryption des\n");
 $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 group 1\n");
 $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 hash sha\n");
 $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 lifetime 12\n");
 $telnet->cmd ("ike preferences 1 ip-address 0.0.0.0 lifebytes 0\n");
 $telnet->cmd ("interface internal-atm-pvc 1/$vci 3/2 1/$vci\n");
     $telnet->cmd ("ip address 10.$ip.$ip.2 netmask 255.255.255.0\n");
 $telnet->cmd ("up\n");
 $telnet->cmd ("up\n");
 $telnet->cmd ("virtual-interface tunnel IPSEC$vti policy-name policy7\n");
 $telnet->cmd ("ip unnumbered\n");
 $telnet->cmd ("up\n");
 $telnet->cmd ("up\n");
 $telnet->cmd ("up\n");
 }
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to