Verification - WeOnlyDo Discussion board

Verification (General questions)

by schenkp, Friday, November 18, 2011, 18:04 (4565 days ago)

Is there a way to use this product to simple determine that the remote system you are connecting to is a Linux system. Can you please help me modify the code below to use this product to determine the above.


string testFile = @ C:Windows ;
private void button5_Click(object sender, EventArgs e)
{
Check_file_Existence(testFile);
}


private void Check_file_Existence(string sFileName)
{
try
{
if (Directory.Exists(sFileName) == true)
{
// return true;
MessageBox.Show( FILE EXIST );
}
else
{
// return false;
MessageBox.Show( FILE DOES NOT EXIST );
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
// return false;
}

}

Re: Verification

by woddrazen, Friday, November 18, 2011, 18:09 (4565 days ago) @ schenkp

Hi,


When you are connected to server you can send this command to determine if you are on linux box:

uname

I'm not sure how to add this to your code. I don't see where you execute commands with wodSSH?


Regards,
Drazen

Re: Verification

by schenkp, Friday, November 18, 2011, 18:52 (4565 days ago) @ woddrazen

THis is the code that we are currently using in production.... Just not sure how to intergrate it into the above code.

WeOnlyDo.Client.SSH ssh1 = new WeOnlyDo.Client.SSH();

System.Collections.IDictionary envVars = Environment.GetEnvironmentVariables();

string endVLC = killall -q vlc ;

String hostname_value = ;

private void data(string streamPath)
{
System.Collections.IDictionary envVars = Environment.GetEnvironmentVariables();

foreach (System.Collections.DictionaryEntry envVar in envVars)
{

if (envVar.Key.ToString() == ThinConnectedFrom )
{
hostname_value = envVar.Value.ToString();
}
}

WeOnlyDo.Client.SSH ssh1 = new WeOnlyDo.Client.SSH();
ssh1.Hostname = hostname_value;
ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto;
ssh1.Login = user ;
ssh1.Password = user ;
ssh1.Blocking = true;
ssh1.Command = streamPath;

try
{
ssh1.LicenseKey = XXXX ;
ssh1.Connect();
String result = ssh1.Receive();
System.IO.File.WriteAllText( C:\Temp\TV.txt , result);

}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}

}

Re: Verification

by woddrazen, Friday, November 18, 2011, 19:01 (4565 days ago) @ schenkp

Hi,


You can send uname command inside ssh1.Command line.

Hope this helps.


Regards,
Drazen