Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've been trying to think of a method to do this for days, but have not come up with anything yet. Ideally, this is what I'm looking to do:

From a windows XP machine, I need to open an SSH connection to a remote host, send the arp command, and pull the text results of the command back for use on the client. I will need to parse this data and preferably produce a 2D array of IPs and MAC addresses. There will be no shared keys, this is all done with a username and password that will always be different, they will need to be fed into the command via variables that will be pulled from a database using an autoit script based on the WAN ip of the remote host.

Now the actual parsing of the data and creation of the array will be easy if I can just get the text of the arp table. Is there any way to ssh to a remote host, run a command and return the data from that command to the client in a batch script or perl script (it is ok if it writes the text to a file, I can read it out of the file later, I just need it to get to the client)?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Using PuTTY's plink:

plink <server> arp

If that doesn't work:

echo arp | plink <server>

If the system is running Linux and the ip command is available, use it. The format is easier to parse:

plink <server> /sbin/ip -o -f inet neigh

plink <server> /sbin/ip -o -f inet6 neigh
share|improve this answer
all systems that will run this will be Windows XP boxes. Does plink return the results of the command it runs on stdout? If so, the first option you specify will probably work, but I'll need to test. –  MaQleod Mar 7 '11 at 11:07
@MaQleod: I meant the target system (the router or whatever). –  grawity Mar 7 '11 at 11:09
plink was the easiest to implement. The command I used was: plink.exe user@server -pw password -m arp –  MaQleod Mar 11 '11 at 23:10

Using PuTTY, you can specify the username and password as follows:

  • putty -pw password username@hostname

Additionally, the "-m" command-line switch will also allow you to specify a text file to read commands from for execution on the server after connecting.

You can download PuTTY from here:

  PuTTY (free and open source)

share|improve this answer
Logging in with putty is the easy part, other parts of this project do that already. But there is no text file with commands on the server and the server will always be different (there are over 5000 in the field, so adding this text file to all of them is not on option). Furthermore, I need to be able to pull the data the command provides back to the client in a form that can be parsed, that doesn't let me do that. –  MaQleod Mar 7 '11 at 8:42
I interpreted that wrong. -m will work for executing commands as that reads from a local file, but it does not provide me a way for returning and parsing the data. I need to somehow manage that with a script that this putty command would be encased in –  MaQleod Mar 7 '11 at 8:51
Use the logging feature in PuTTY (either save the logging setting to the default session, or Save the desired presets as a session name and use the "-load" command-line switch to specify that session). The logging feature provides a variety of options for how much output to save in the log file, although it defaults to no logging at all. –  Randolf Richardson Mar 7 '11 at 9:22
hmm, logging is something I hadn't thought about. This will be run by dozen's of clients, all with default settings. I would need to enable logging for the session in the command that executes putty. I'm not sure this is possible. I wonder if I can create a saved session with logging that could then be invoked by all other clients, but then inject the other parameters (username, host, password) in the command line as usual. I'll have to test that out. –  MaQleod Mar 7 '11 at 9:32
I didn't see a command-line argument in the documentation to control logging, and I don't know off-hand how PuTTY stores sessions? –  Randolf Richardson Mar 7 '11 at 9:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.