Solved

Code example for plink.exe redirect of results

Posted on 2011-09-29
5
1,935 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
Russell_Venable earned 500 total points
ID: 36894644
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
ID: 37184032
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
ID: 37260985
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

691 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