manit Posted April 9, 2014 Share Posted April 9, 2014 (edited) I wrote this program to accept a number separated comma list with allowance of range using startnumber-endnumber This program will help me to run same sequence of commands (which involve checking process ,contents of cfg file,pinging gateway after manipulating wan0,three-digit-number interface address) on different systems with unique IP as fed by user. expandcollapse popup$userinput = InputBox("VOIP IP separated by comma,give range using -", "") $ips = StringSplit($userinput,",") For $i = 1 To $ips[0] If StringInStr($ips[$i],"-") Then $vlan = StringSplit($ips[$i],"-") $startvlan = $vlan[1] $endvlan = $vlan[2] MsgBox(1,"range","start ip is "&$startvlan&" end ip is "&$endvlan) Else $startvlan = $ips[$i] $endvlan = $ips[$i] MsgBox(1,"ip","ip is "&$startvlan&" = "&$endvlan) Endif WinActivate ( "Untitled" ) For $i = $startvlan To $endvlan Step 1 Send("telnet 192.168.7."&$i&"{ENTER}") ;Sleep(1000) Send("root{ENTER}") ;Sleep(1000) Send("root{ENTER}") ;Sleep(1000) Send("ps | grep -i audio{ENTER}") ;Sleep(1000) Send("cat /tmp/CdotGponVoip.cfg | grep -i 2659{ENTER}") ;Sleep(1000) Send("ifconfig | grep -EA1 'wan0\.[0-9][0-9][0-9][{^}0-9]' {ENTER}") ;Sleep(1000) Send("pingip=$(ifconfig |sed -rn '/wan0.[0-9][0-9][0-9][{^}0-9]/{{}np{}}'|sed 's/inet addr:\(.*\) Bcast.*/\1/'){ENTER}") ;Sleep(1000) Send("echo $pingip{ENTER}") ;Sleep(1000) Send("pinggw=$( echo $pingip | sed -r 's/\.[0-9]$/\.1/'){ENTER}") ;Sleep(1000) Send("echo $pinggw{ENTER}") ;Sleep(1000) Send("ping -c 2 $pinggw{ENTER}") ;Sleep(1000) Send("exit{ENTER}") Msgbox(0,"Operation halted","Continue?") Next Next Edited April 9, 2014 by manit Link to comment Share on other sites More sharing options...
JohnOne Posted April 9, 2014 Share Posted April 9, 2014 Not sure I can determine a question in your post. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
manit Posted April 10, 2014 Author Share Posted April 10, 2014 (edited) Sorry , I meant to say - when I give user input as 1,2-5,4,7-3,8,9 .I see that commands get run for 1,4,9. The code written above will pass commands to newly opened notepad window. I am unable to find any fault in my program. Can you help ? Edited April 10, 2014 by manit Link to comment Share on other sites More sharing options...
manit Posted April 11, 2014 Author Share Posted April 11, 2014 That is so stupid of me, I used the same variable i at two places . Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now