Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Tamir.SharpSsh;
- using System.Collections;
- using System.IO;
- namespace mc_connect
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- public class Util
- {
- /// <summary>
- /// Get input from the user
- /// </summary>
- ///
- public static SshConnectionInfo GetInput()
- {
- string sFilename = @"server.txt";
- string sContent = "";
- StreamReader myFile = new StreamReader(sFilename, System.Text.Encoding.Default);
- sContent = myFile.ReadToEnd();
- myFile.Close();
- string[] words = sContent.Split(':');
- SshConnectionInfo info = new SshConnectionInfo();
- info.Host = words[1];
- info.User = words[3];
- info.Pass = words[5];
- return info;
- }
- }
- public struct SshConnectionInfo
- {
- public string Host;
- public string User;
- public string Pass;
- public string IdentityFile;
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string sFilename = @"server.txt";
- string sContent = "";
- StreamReader myFile = new StreamReader(sFilename, System.Text.Encoding.Default);
- sContent = myFile.ReadToEnd();
- myFile.Close();
- string[] words = sContent.Split(':');
- SshConnectionInfo input = Util.GetInput();
- SshExec exec = new SshExec(input.Host, input.User);
- if (input.Pass != null) exec.Password = input.Pass;
- if (input.IdentityFile != null) exec.AddIdentityFile(input.IdentityFile);
- exec.Connect();
- //Command der ausgeführt wird
- exec.RunCommand("cd Bukkit && screen -dmSL mcserver java -Xincgc -Xmx3000m -jar craftbukkit.jar ");
- exec.Close();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- SshConnectionInfo input = Util.GetInput();
- SshExec exec = new SshExec(input.Host, input.User);
- if (input.Pass != null) exec.Password = input.Pass;
- if (input.IdentityFile != null) exec.AddIdentityFile(input.IdentityFile);
- exec.Connect();
- //Command der ausgeführt wird
- exec.RunCommand("screen -r mcserver -X quit");
- exec.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement