Solved

Code example for plink.exe redirect of results

Posted on 2011-09-29
5
1,815 Views
Last Modified: 2012-05-12
I am hoping somebody could provide a code example of how plink.exe can be used to log into a linux server, run a few commands and direct all of the ouput to a textbox within VB.net 2010.

I know the command line to get the connection....
       Dim Unix_User_Name As String = "XXX"
        Dim Unix_User_Password As String = "XXX"
        Dim NDS_Start_SIT_Putty_Command_Value As String = "C:\plink.exe " + Unix_User_Name + "@spongeshrimp.grhq.XXX.com -pw " + Unix_User_Password

Open in new window


But then what I want to do is a....
ls -la

Open in new window


And then capture all the reults of that command in a textbox.  I know this is done through streamreading however I am not that up on how this is acomplished.  I just need a code example.

Thank you.
0
Comment
Question by:larrylroberts
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Russell_Venable earned 500 total points
Comment Utility
Hi Larryltoberts,

First you are going to need to register the directory that has plink in it by setting it's user environment for system and user (depends on your system). You can set the path by using the cmd prompt and setting the path using the "PATH" command or going to my computer and right click and select properties, goto "advanced" tab and look towards the bottom
for Environment variables click this, next go to system variables and open up PATH and add your directory to plink after the last " ; ". Now that this is done you will need to reboot for this to take effect.

This article here is a perfect example of command prompt redirection using VB.NET. http://www.vbforums.com/showthread.php?t=381405.

After you have d/l and compiled you can use plink like so.
create a text file named commands.txt and place the commands you wish to run and save the text file now open the VB.NET project compile and run the binary and run that command it should give you exactly what your asking for.
Plink -ssh -l <username> -pw <yourpass> -t -m commands.txt -s
0
 
LVL 15

Expert Comment

by:Russell_Venable
Comment Utility
Well I gave the answer. I answered what the OP asked for. Just didn't get a response back. This will do exactly as wanted.
0
 
LVL 53

Expert Comment

by:Dhaest
Comment Utility
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is an explanation of a simple data model to help parse a JSON feed
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now