I am using plink in windows to connect to a network device and capture the output to a file. That part works great.
Here is an example of the command line I am putting in a batch program.
plink.exe -v -l [username] -pw [password] [ip address] -m "c:\empty.txt" < "c:\commands.txt" > "c:\command_output.txt"
command_output.txt only contains the output from the ssh session.
I want to add some error handling in case it cannot connect for example. I can't figure out how to get the connection messages to go to a file. They go to the command window only. I have tried using start /c cmd.exe from another batch program and redirectiong that output to another log file. Tried using 2>&1. I get nothing. It always just goes to the command window.
Here is and example of what I want to capture.
Looking up host "xxx.xxx.xxx.xxx"
Connecting to xxx.xxx.xxx.xxx port 22
Failed to connect to xxx.xxx.xxx.xxx: Network error: Connection timed out
Network error: Connection timed out
FATAL ERROR: Network error: Connection timed out