Renci SSH中的问题 [英] Problem in Renci SSH

查看:63
本文介绍了Renci SSH中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好朋友我有这个代码的问题这是一个简单的代码来执行Linux的代码,但这不起作用,当我不使用

Hello Friends I have problem with this code this is a simple code to execute codes to Linux but this is not working and this code is working when I am not using

引用:

+ something1 + something2

+ something1 + something2

当我使用此代码时,如

引用:

(perl something .pl something1value something2value)

("perl something.pl something1value something2value")

任何人都可以告诉我一个解决方案,我的代码在下面请帮助我

can anyone please tell me a solution my code is below please help me

Public Class Form1

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim IP As String = "xxx.xxx.xxx.xxx"
        Dim Username As String = "root"
        Dim Password As String = "mypassword"
        Dim cmd As Renci.SshNet.SshCommand
        Dim connInfo As New Renci.SshNet.PasswordConnectionInfo(IP, Username, Password)
        Dim sshClient As New Renci.SshNet.SshClient(connInfo)
        Dim something As String = TextBox1.Text
        Dim something1 As String = TextBox2.Text
        Dim something2 As String = TextBox3.Text
        sshClient.Connect()
        cmd = sshClient.RunCommand("perl something.pl" + something1 + something2)
        Label1.Text = cmd.Result
    End Sub
End Class

推荐答案

我认为你错过了空格。假设 something1 包含值something1value something2 包含something2value sshClient.RunCommand(perl something.pl+ something1 + something2)将执行以下命令命令: something.plsomething1valuesomething2value 。你需要在参数之间插入空格。



一般来说,当你必须发送一个命令时,你会将它全部放在一个字符串中并打印出来(在控制台或消息框中),以便您可以清楚地看到发送的内容及其失败的原因。
I think you arre missing the spaces. Assuming that something1 contains the value "something1value" and something2 contains "something2value", sshClient.RunCommand("perl something.pl" + something1 + something2) will execute the following command: something.plsomething1valuesomething2value. You need to insert spaces between the parameters.

Generally, when you have to send a command, like this, you would put it all in one string and print it (in the console, or in a messagebox) so that you can clearly see what you send and why it fails.


您需要将空格添加为字符串,否则它们不会在你的最后命令。



试试这个:

You need to add the spaces as strings, else they won''t be in your final command.

Try this:
sshClient.RunCommand("perl something.pl " + something1 + " " + something2)





(注意之后的空格something.pl ,以及引号之间的空格。)



(Notice the space after something.pl, and the space between quotes.)


这篇关于Renci SSH中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆