Solved plink to a list of IP's, then output command results to text

July 24, 2013 at 06:17:16
Specs: Windows 7
I am looking to make a batch file that executes a plink session. The batch file pulls the ip address that it will be ssh'ing to via a text document called ips.txt . That plink session will be running a single command that is located in command.txt . The results of the command that plink executes should be output to output.txt. This batch file should loop until it finishes going through the list of 300+ ip addresses.
If anyone could assist me with some guidance, it would be GREATLY appreciated!

See More: plink to a list of IPs, then output command results to text

Report •


#1
July 24, 2013 at 06:50:08
Okay, I'm sick, tired, and the room won't stop spinning, so let's see if I got this straight:
• ips.txt contains a list of IPs
• For each IP, connect using plink -ssh -batch -m command.txt
• Save the results to a single file, output.txt

Note that you don't specify logging in, so I assume you've set up public key authentication, and that you've connected once to those 300+ IPs using PuTTY to verify the host key.

How To Ask Questions The Smart Way


Report •

#2
July 24, 2013 at 07:54:11
Lol

• Correct, ips.txt contains a list of IPs
• For each IP, I connect using echo y | plink -ssh %IP_PULLED_FROM_ips.txt% -l username -pw password -m command.txt

I do not have public key authentication setup, right now it just echos "y" instead, seems to be a quick & dirty fix.


Report •

#3
July 24, 2013 at 09:14:21
✔ Best Answer
Fair enough.
FOR /F %%a IN (ips.txt) DO (echo y | plink -ssh -l username -pw password -m command.txt %%a) > output.txt 2>&1

How To Ask Questions The Smart Way


Report •

Related Solutions


Ask Question