我正在尝试从名为teste.sh
的文件中运行以下命令kpm restore
k web
当我打开终端cd到正确的文件夹并执行“sh teste.sh”时,它们运行正常,但是当我尝试在monodevelop上运行以下命令时:
using System;
using System.Diagnostics;
namespace terminalcommandteste
{
class MainClass
{
public static void Main (string[] args)
{
StartWebServer ();
}
public static void StartWebServer ()
{
string command = "sh";
//string argss = "/home/daniel/Downloads/HelloWorldVNext-master/src/hellomvc/teste.sh";
string dir = "/home/daniel/Downloads/HelloWorldVNext-master/src/hellomvc/";
string argss = "teste.sh";
ProcessStartInfo procInfo = new ProcessStartInfo ();
procInfo.WindowStyle = ProcessWindowStyle.Normal;
procInfo.UseShellExecute = false;
procInfo.FileName = command;
procInfo.Arguments = argss;
procInfo.WorkingDirectory = dir;
Process.Start (procInfo);
}
}
}
终端的响应是:
teste.sh: 1: teste.sh: kpm: not found
teste.sh: 2: teste.sh: k: not found
Press any key to continue...
答案 0 :(得分:0)
通过https://jabbr.net/#/rooms/AspNetvNext聊天中 alexkoeplinger , Alxandr.me 和 Yantr.io 来管理解决我的问题
将项目更改为
using System;
using System.Diagnostics;
namespace terminalcommandteste
{
class MainClass
{
public static void Main (string[] args)
{
StartWebServer ();
}
public static void StartWebServer ()
{
string command = "/bin/bash";
//string argss = "/home/daniel/Downloads/HelloWorldVNext-master/src/hellomvc/teste.sh";
string dir = "/home/daniel/Downloads/HelloWorldVNext-master/src/hellomvc/";
string argss = "teste.sh";
ProcessStartInfo procInfo = new ProcessStartInfo ();
procInfo.WindowStyle = ProcessWindowStyle.Normal;
procInfo.UseShellExecute = false;
procInfo.FileName = command;
procInfo.Arguments = argss;
procInfo.WorkingDirectory = dir;
Process.Start (procInfo).WaitForExit();
}
}
}
和teste.sh到
#!/bin/bash
source "/home/daniel/.kre/kvm/kvm.sh"
kpm restore
k web