#145334 - 2005-08-11 01:37 PM
Reading/Writing from /to Command prompt
|
AstaaLavista
Starting to like KiXtart
Registered: 2005-08-11
Posts: 111
Loc: Gujarat, India.
|
Hi, Please excuse me. I am new to Kixtart. Using Kixtart, is it possible to write automated scripts which can READ from & WRITE to “Command Prompt” windows.
Basically, my issue is that I want to check accessibility to several IPs. These IPs have several ports open. Using Telnet, I want to check if the ports are open or not. Thus, on the command prompt window, if I see the statement 'Could not open connection to the host.. Connect failed' , it means the port is NOT opened. Thus, if I am able to read from the command prompt windows, the above thing wud be achieved. If anybody knows better method of checking the accessibility, please let me know. Thanks in advance.
|
|
Top
|
|
|
|
#145337 - 2005-08-11 02:50 PM
Re: Reading/Writing from /to Command prompt
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
look into WSHPipe() from the udf forum.
It will capture the output from a cndline app, and dump the output into an array to make it easier to parse.
Otherwise, you will have to redirect output into a text file and then read the file into an array, etc...
|
|
Top
|
|
|
|
#145340 - 2005-08-12 11:05 AM
Re: Reading/Writing from /to Command prompt
|
AstaaLavista
Starting to like KiXtart
Registered: 2005-08-11
Posts: 111
Loc: Gujarat, India.
|
Checking the value of @error does not help. 
I tried $rc=WshPipe("telnet SOME I.P. 80")
For both the open, closed ports, it displayed --> 0 | The operation completed successfully.
I also checked all the commands of telnet. Its not possible to redirect its output.
I just want to write a script that will automate the telnet process. i.e. i will take the list of I.P. from a file and using the script telnet to all these I.P. If the port is NOT open then I will get an error 'Could not open connection to the host'. This error will be recorded using kixtart (somehow, but unfortunately I dont know & thats what I am asking)  Is it possible using Kixtart. Please help.
Edited by Ziangi_Jones (2005-08-12 11:09 AM)
|
|
Top
|
|
|
|
#145341 - 2005-08-12 12:34 PM
Re: Reading/Writing from /to Command prompt
|
Witto
MM club member
   
Registered: 2004-09-29
Posts: 1828
Loc: Belgium
|
If I try Shawn's advise Code:
Break On Shell "PING "+@WKSTA ? @ERROR": "@SERROR Shell "PING 192.168.222.3" ? @ERROR": "@SERROR
I know that 192.168.222.3 is non-existant The @ERROR is 1 and @SERROR tells me the function is wrong.
Edited by Witto (2005-08-12 12:36 PM)
|
|
Top
|
|
|
|
#145344 - 2005-08-12 02:35 PM
Re: Reading/Writing from /to Command prompt
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
Code:
Shell 'PortQry.exe -n '+$ipaddr+' -e 135 -nr -q' $PC = iif(@ERROR,'Not Windows','Windows') ? $pc
Edited by Radimus (2005-08-12 02:58 PM)
|
|
Top
|
|
|
|
#145345 - 2005-08-12 02:37 PM
Re: Reading/Writing from /to Command prompt
|
Shawn
Administrator
   
Registered: 1999-08-13
Posts: 8611
|
Expanding on Witto's comments, and assuming your looking to test just accessibility versus whether the telnet ports are specificically open or not, this code works. Just change the $WKSTA variable to test good and bad hostnames.
Code:
break on
$wksta = @WKSTA
shell '%comspec% /c ping -n 2 $wksta | find /i "TTL=" >NUL 2>NUL'
if @ERROR = 0 ?"$wksta is accessible!" else ?"$wksta is not accessible!" endif
exit 0
Or - are you looking to test specifically whether telnet is available ?
-Shawn
|
|
Top
|
|
|
|
#145350 - 2005-08-22 11:52 AM
Re: Reading/Writing from /to Command prompt
|
AstaaLavista
Starting to like KiXtart
Registered: 2005-08-11
Posts: 111
Loc: Gujarat, India.
|
Hi All, Sorry for the late reply. I had been out of station.
Quote:
Or - are you looking to test specifically whether telnet is available ?
-Shawn
This was what I was looking for.  I will try the code sent by Allen. I hope my problem will be solved. Thanks a lot
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
0 registered
and 1471 anonymous users online.
|
|
|