Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Code example for plink.exe redirect of results

Posted on 2011-09-29
5
Medium Priority
?
2,016 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

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Starting up a Project

610 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