# Run Telnet From Batch File



## benallenuk

Hi guys, Im after a way to telnet into tivo, run a few commands and leave the cmd window open.

Ive tried the following from a batch file, but it doesnt wait.

telnet 192.168.2.100
cd ..
cd vserver
./vserver

any ideas?

cheers


----------



## terryeden

add cmd to the end of the .BAT file should work.


----------



## Ian_m

The standard Windows Telnet is not scriptable.

I was looking for something like this ages ago, schedule a script on PC to run to Telnet to TiVo, run GZIP of HACK directory and FTP back onto PC.

If you Google to "scriptable telnet" you will find solutions, though I did not have too much success with the free ones and the pay one were too pricey and complicated for what I needed.

A better solution, though I never did would be to run the GZIP backup as a CRON task on TiVo and have scheduled FTP task on PC to retreive the archive.


----------



## tefster

You could install cygwin, and use the telnet client bundled with it plus the port of "expect" that's bundled with it (just select them from the menu when you install cygwin and it'll download them).

Expect is a utility which is purposely designed to script command-line/unscriptable applications, you could write an expect script which looks like :-

# tivo.expect
set timeout 20
spawn telnet tivo.ip.address
expect "Tivoprompt"
send "cd ..\n"
expect "Tivoprompt"
send "cd vserver\r"
expect "Tivoprompt"
send "./vserver\r"
interact

(change Tivoprompt to whatever your Tivo shell prompt is set to) and then run it with "expect tivo.expect"

The "send" and "expect" commands are self explanatory, the "interact" means that at the end of the script the telnet session control is handed back to the keyboard.

(The syntax for the above was typed from memory, but I'm sure you see what I mean).


----------



## tefster

>The standard Windows Telnet is not scriptable.

You could also check out the windows version of NetCat. That would allow you to throw commands at the telnet port in a scriptable way, but its really just useful as a raw "throw bytes at the telnet port" tool, whereas expect would allow you to manage and script the whole process - including timeouts, error checking, etc


----------



## benallenuk

cheers will give it a go


----------



## zhitenglin

email to [email protected]
i send you a copy


----------

