Plink wait problem

Hi,
I have run into a problem to which i can't seem to find any solution, posting here is my last resort.

Problem:
I am using plink to access my router and run a few configuration commands. When in enter configurations mode, instead of sending next command plink keeps on waiting for manual input. It only sends command while not in configuration mode. I need a way to make it send commands while router is in configuration mode.

Router is Cisco ASR 9001 (IOS XR)
using ssh to connect to router
command used to loging to router :

plink.exe username@routerip -C -pw mypassword -m G:\commands.txt"

Commands in commands.txt

show interface description | i Gi0/0/1   ( runs correctly)
configure terminal    (runs correctly)
interface Gi0/0/1     (command is not send to router instead it keeps on waiting on CLI. Command can be manually sent from keyboard, but that is useless as i want to automate it)

While waiting in configure mode, I can manually send the command by keyboard but then it kills the reason for using a batch file. However, if i manually exit from configuration mode, plink then resumes to send the next comamnds.

So I am stuck as how to make it send commands while in configuration mode.

Rather, I suspect it does not wait and sends the entire file in one giant block which gets 99% ignored.

For dealing with interactive situations like this, you'd usually use the expect language, which you can tell to wait for a matching response before sending more text. However, Windows does not have actual terminals for expect to use, so I'm unsure if this can be accomplished.

I have tested it with several commands. Plink send them one by one and as i already mentioned that when i exit the configuration mode, it resumes normal operation. The problem only comes when router goes into configuration mode.

Another crude way to deal with this would be slowing down the input. I don't think Windows has the very basic functionality needed to do this, but with busybox-w32 you can do:

busybox bash -c "while read -r LINE ; do echo $LINE ; sleep 1 ; done" < inputfile.txt | plink username@host -pw password

This will flatten any whitespace in your input file. I'm not sure how to avoid that without using an external script file. Does it matter for your input?

plink does not wait. It is a very primitive non-terminal with no such feature. It sends as fast as the socket will allow it.

The usual problem with scripting interactive interfaces is periods of time when anything you type will be ignored. This seldom matters to a human, but a program which will happily send the entire buffer while the router's occupied examining its own navel.

Mate, input is being taken fine, rather plink itself goes into some kind of wait from router. what i think is that plink interprets it as router is busy while in configure mode. The second router goes to privilege mode, operation resumes as normal.

If it really is waiting on keyboard, have you tried just

plink < textfile

? Windows isn't smart enough to tell the difference between textfile and terminal, so it might actually work as a "fake keyboard".

CLI is open when plink is running and i can see everything on screen. When router goes into configruation mode, everything just stops. I can input commands from my keyboard. So i give "exit" command to quit configuration mode and then again operation resumes as normal, the commands again start coming from batch file.

If following commands are in batch file :

configure terminal
interface gi0/0/1
shutdown
commit

This is how it actually works:

ASR9001#
ASR9001#configure terminal
ASR9001(config)#    -> At this point, it just keeps on waiting until i manually input command from keyboard to exit configuration mode. I also tried running other commands while router is in config mode, and they run properly. Then when it exit configuration mode this is how it goes

ASR9001#interface gi0/0/1
                                  ^
% Invalid input detected at '^' marker.

ASR9001#shutdown
                                  ^
% Invalid input detected at '^' marker.
ASR9001#commit
                                  ^
% Invalid input detected at '^' marker.



Total combined output will be this :

ASR9001#
ASR9001#configure terminal
ASR9001(config)#exit         (Typed in manually)
ASR9001#interface gi0/0/1
                                  ^
% Invalid input detected at '^' marker.

ASR9001#shutdown
                                  ^
% Invalid input detected at '^' marker.
ASR9001#commit
                                  ^
% Invalid input detected at '^' marker.

Did you get my suggestion of redirecting the file into plink so it reads it as 'keyboard'?