Link to home
Start Free TrialLog in
Avatar of CES
CES

asked on

Send a pause through plink (putty) program

I am writing a script using plink to send commands remotely to network devices (routers and switches) and then output the console to a text file.  Using the below, I can successfully acheive this but with some strange results:

(plink -ssh user@1.2.3.4 -pw password <.\commands.txt)>output.txt 2>&1

The resulting output.txt file actually shows the command output and then all of the login banner mumbo jumo you get when you log into a device normally (***WARNING*** THIS IS A PRIVATE COMPUTER SYSTEM, etc...)
So my format ends up being:

- results
- login banner

I am having trouble getting the format correct to send a pause trough plink so that my output file shows the results as if I was logged in:

- login banner
- results

Any suggestions?  or is this even possible?
Avatar of netcmh
netcmh
Flag of United States of America image

Is the sequence in the commands.txt correct? Can you paste the contents?

plink -ssh user@1.2.3.4 -pw password <.\commands.txt >output.txt 2>&1 should work.
Avatar of CES
CES

ASKER

For testing purposes, its a simple show version.  I added a pause also to test so below is the contents of the file:

pause

show version


Which still results in the results followed by login banner.  It's almost as if the commands get passed too quickly, which is making me wonder if what I want is possible or not
While we wait for other experts jump in and assist, can you try doing something like the below?

Batch file:
echo Time %TIME% %DATE% >> switch.log
ping 1.2.3.4 >> switch.log 2>> error.log
IF %ERRORLEVEL% EQU 0 echo 1.2.3.4 is up! >> switch.log
plink -ssh user@1.2.3.4 -pw password "show clock" >> switch.log 2>> error.log
plink -ssh user@1.2.3.4 -pw password "show version" >> switch.log 2>> error.log
Avatar of CES

ASKER

Please close this topic.  I have found another solution to get the printout needed
Can you share how? I'd like to know. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of CES
CES

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Glad I could help. Yeah, you really didn't need the commands to be enclosed in brackets.
My comment ID: 42015837 helped guide the OP to the solution.

Comment ID: 42015881 provided other options.
Thank you