Sign in to follow this  
Followers 0
manit

simulating keystroke after processing number input

4 posts in this topic

#1 ·  Posted (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.

$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 by manit

Share this post


Link to post
Share on other sites



#3 ·  Posted (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 by manit

Share this post


Link to post
Share on other sites

That is so stupid of me,

I used the same variable i at two places .

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0