Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Writting telnet output to file

2,168 views
Skip to first unread message

Cosmic Cruizer

unread,
Apr 13, 2008, 6:00:43 PM4/13/08
to
Is it possible to write the output of a vbscript initiated telnet sesson to
a file?

I have the following, but now I need to write the results to a file:

Set oShell = CreateObject("WScript.Shell")
oShell.Run "Telnet www.xxx.com 80"
oShell.AppActivate "Telnet"
WScript.Sleep 500
oShell.SendKeys("GET /index.html HTTP/1.1")
WScript.Sleep 500
oShell.SendKeys("{Enter}")
WScript.Sleep 500
oShell.SendKeys("{Enter}")

Thanks

Tom Lavedas

unread,
Apr 14, 2008, 9:23:22 AM4/14/08
to

The most frequent advice I have seen on this subject is to get a
different, scriptable telnet client. For more on the subject, try a
groups.google search on telnet script.

Tom Lavedas
===========
http://members.cox.net/tglbatch/wsh/

Harvey Colwell

unread,
Apr 14, 2008, 9:56:51 AM4/14/08
to
Microsoft has an ActiveX component that allows you to emulate any TCP/IP
type communications (Telnet, SMTP, FTP, etc), but it not free.


For Telnet, I can highly recommend TST10.exe
(http://www.winsite.com/bin/Info?500000000873). I've built some good
SMTP/POP troubleshooting tools with it and some Cisco router configuration
utilities. vbScript allows you to created the input data file on the fly,
and TST10 can automatically save the output (session) data to a file.

"Cosmic Cruizer" <XXjbh...@white-star.com> wrote in message
news:Xns9A7F98A22C960...@207.115.17.102...

Cosmic Cruizer

unread,
Apr 14, 2008, 9:56:11 PM4/14/08
to
The project is to first try to do it with only vbscript. If that's not
possible, which I'm seeing it probably isn't without needing to to start
swap out telnet or adding dll's, etc, then it will be just as easy to
create a wrapper for a perl script and use it instead.

Thanks.

"Harvey Colwell" <Harvey...@effingham.net> wrote in
news:#bZhndjn...@TK2MSFTNGP03.phx.gbl:

Tom Lavedas

unread,
Apr 15, 2008, 8:48:47 AM4/15/08
to
On Apr 14, 9:56 pm, Cosmic Cruizer <XXjbhun...@white-star.com> wrote:
> The project is to first try to do it with only vbscript. If that's not
> possible, which I'm seeing it probably isn't without needing to to start
> swap out telnet or adding dll's, etc, then it will be just as easy to
> create a wrapper for a perl script and use it instead.
>
> Thanks.
>
> "Harvey Colwell" <HarveyColw...@effingham.net> wrote innews:#bZhndjn...@TK2MSFTNGP03.phx.gbl:

>
> > Microsoft has an ActiveX component that allows you to emulate any
> > TCP/IP type communications (Telnet, SMTP, FTP, etc), but it not free.
>
> > For Telnet, I can highly recommend TST10.exe
> > (http://www.winsite.com/bin/Info?500000000873). I've built some good
> > SMTP/POP troubleshooting tools with it and some Cisco router
> > configuration utilities. vbScript allows you to created the input data
> > file on the fly, and TST10 can automatically save the output (session)
> > data to a file.
>
> > "Cosmic Cruizer" <XXjbhun...@white-star.com> wrote in message

> >news:Xns9A7F98A22C960...@207.115.17.102...
> >> Is it possible to write the output of a vbscript initiated telnet
> >> sesson to
> >> a file?
>
> >> I have the following, but now I need to write the results to a file:
>
> >> Set oShell = CreateObject("WScript.Shell")
> >> oShell.Run "Telnetwww.xxx.com80"
> >> oShell.AppActivate "Telnet"
> >> WScript.Sleep 500
> >> oShell.SendKeys("GET /index.html HTTP/1.1")
> >> WScript.Sleep 500
> >> oShell.SendKeys("{Enter}")
> >> WScript.Sleep 500
> >> oShell.SendKeys("{Enter}")
>
> >> Thanks

Have you looked at the telnet help? The client for XP, at least, has
a -f switch that provides a client side log. Might that serve your
need?

Also, the AppActivate function can close the loop around the start of
the telnet session to be a bit more robust ...

with CreateObject("WScript.Shell")
.Run "Telnet -f log.txt -t ansi www.xxx.com 80"
do until .AppActivate("Telnet") : WScript.Sleep 50 : loop
.SendKeys "GET /index.html HTTP/1.1"
WScript.Sleep 500
.SendKeys "{Enter 2}"
end with

Cosmic Cruizer

unread,
Apr 16, 2008, 9:52:59 PM4/16/08
to
Tom Lavedas <tglb...@cox.net> wrote in
news:f79f11ef-4455-4079...@c65g2000hsa.googlegroups.com:

> On Apr 14, 9:56 pm, Cosmic Cruizer <XXjbhun...@white-star.com> wrote:
>> The project is to first try to do it with only vbscript. If that's
>> not possible, which I'm seeing it probably isn't without needing to
>> to start swap out telnet or adding dll's, etc, then it will be just
>> as easy to create a wrapper for a perl script and use it instead.
>>
>> Thanks.
>

> Have you looked at the telnet help? The client for XP, at least, has
> a -f switch that provides a client side log. Might that serve your
> need?
>
> Also, the AppActivate function can close the loop around the start of
> the telnet session to be a bit more robust ...
>
> with CreateObject("WScript.Shell")
> .Run "Telnet -f log.txt -t ansi www.xxx.com 80"
> do until .AppActivate("Telnet") : WScript.Sleep 50 : loop
> .SendKeys "GET /index.html HTTP/1.1"
> WScript.Sleep 500
> .SendKeys "{Enter 2}"
> end with
>
> Tom Lavedas
>===========
> http://members.cox.net/tglbatch/wsh/
>

Tom,

The -f flag was the magic ticket. I didn't even know it existed.

Thank you very much!

Reventlov

unread,
Apr 18, 2008, 6:44:46 PM4/18/08
to
Il giorno Tue, 15 Apr 2008 01:56:11 GMT, Cosmic Cruizer <XXjbh...@white-star.com> ha
scritto:

>The project is to first try to do it with only vbscript. If that's not
>possible, which I'm seeing it probably isn't without needing to to start
>swap out telnet or adding dll's, etc, then it will be just as easy to
>create a wrapper for a perl script and use it instead.

I use Netcat (NC). It's only a few kb and doesn't need to be installed.
I create the command file and run it.

' *******************************************************
' PopMail
' Elenca i messaggi di posta elettronica presenti
' su un server pop3 e permette di cancellarli prima
' di cancellarli.
' Lists e.mail messages in a window and allows you
' to choose which ones to delete.
' Cenati Giovanni http://digilander.libero.it/Cenati
' Codice liberamente utilizzabile citando il sito.
' Comandi POP3 Commands http://www.freesoft.org/CIE/RFC/1725/1.htm
' *******************************************************
Title="PopMail - Cenati"
set wshShell = CreateObject("WScript.Shell")
' Crea l'oggetto FileSystemObject
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Const ForWriting = 2

User= inputbox("Nome Casella di posta",title,"reve...@mymail.com")
Password=InputBox("Password",Title,"mypassword")
Server=InputBox("Nome del server pop3",title,"pop.server.com")
if User="" or Password="" or Server="" then wscript.quit

'Creo il file "command.txt" con l'autenticazione e la richiesta
'del numero di messaggi e-mail e la lunghezza in bytes
fso.CreateTextFile "command.txt",true
Set txtStream=fso.OpenTextFile("command.txt",ForWriting)
TxtStream.WriteLine "user " & user
TxtStream.WriteLine "pass " & password
TxtStream.WriteLine "stat" 'Chiede numero messaggi e occupazione totale
TxtStream.WriteLine "quit"
txtStream.Close

'Invia il login e chiede l'elenco dei messaggi
wshShell.run "%comspec% /C nc.exe " & server & " 110 <command.txt >output.txt",7,true


--
Giovanni Cenati (Bergamo, Italy)
Write to "Reventlov" at katamail com
http://digilander.libero.it/Cenati (Esempi e programmi in VbScript)
--

0 new messages