?
Solved

Code example for plink.exe redirect of results

Posted on 2011-09-29
5
Medium Priority
?
1,967 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 2000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Starting up a Project
Suggested Courses

765 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