ProcessStartInfo não reconhecer comando dentro .sh arquivo

votos
2

Estou tentando executar os seguintes comandos em um arquivo chamado teste.sh

kpm restore
k web

Eles correm muito bem quando eu abrir o cd terminal para a pasta correta e fazer teste.sh sh, mas quando tento executar o seguinte em 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);
        }
    }

}

A resposta no terminal é:

teste.sh: 1: teste.sh: kpm: not found
teste.sh: 2: teste.sh: k: not found

Press any key to continue...
Publicado 03/11/2014 em 15:45
fonte usuário
Em outras línguas...                            


1 respostas

votos
0

Conseguiu corrigir o meu problema graças a alexkoeplinger , Alxandr.me e Yantr.io na https://jabbr.net/#/rooms/AspNetvNext bate-papo

mudou o projeto para

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();
        }
    }

}

eo teste.sh para

#!/bin/bash
source "/home/daniel/.kre/kvm/kvm.sh"

kpm restore
k web
Respondeu 03/11/2014 em 16:34
fonte usuário

Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more