재미있는 프로젝트로 저는 C#을 통해 git-cmd.exe 프로세스를 통해 여러 명령을 실행하려고합니다.윈도우가없는 자식 자식 프로세스 bash를 엽니 다
여러 개의 명령을 실행하려면이 코드가 있습니다
var info = new ProcessStartInfo(@"C:\Program Files\Git\git-cmd.exe");
info.RedirectStandardInput = true;
info.UseShellExecute = false;
var gitProcess = new Process { StartInfo = info };
gitProcess.Start();
using (StreamWriter sw = gitProcess.StandardInput)
{
// commands here
}
gitProcess.WaitForExit();
이 잘 실행,하지만 나는 다음과 같은 명령을 실행하려고하면, 나는 몇 가지 메시지를 받고 있습니다.
명령 (https://stackoverflow.com/a/33656490/1671161) :
curl -X POST -v -u username:password https://api.bitbucket.org/2.0/repositories/TeamName/reponame -H "Content-Type: application/json" -d '{"scm": "git", "is_private": true, "fork-policy": "no_public_forks", "has_issues": true}'
메시지 :
Note: Unnecessary use of -X or --request, POST is already inferred.
* timeout on name lookup is not supported
* Trying 2401:1d80:1010::153...
* Connected to api.bitbucket.org (2401:1d80:1010::153) port 443 (#0)
#more messages, seems OK to me so far, but then this:
Connection state changed (MAX_CONCURRENT_STREAMS updated)!
* We are completely uploaded and fine
* HTTP 1.0, assume close after body
< HTTP/2 400
< server: nginx/1.6.2
< vary: Authorization, Cookie
< content-type: text/plain
< strict-transport-security: max-age=31536000
< date: Wed, 10 Aug 2016 17:34:57 GMT
< x-served-by: app-112
< x-static-version: 89c5b48218a9
< etag: "825644f747baab2c00e420dbbc39e4b3"
< x-render-time: 0.0194010734558
< x-accepted-oauth-scopes: repository:admin
< x-version: 89c5b48218a9
< x-request-count: 459
< x-frame-options: SAMEORIGIN
< content-length: 11
<
Bad Request* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
Note: Unnecessary use of -X or --request, POST is already inferred.
* Rebuilt URL to: git,/
* timeout on name lookup is not supported
* getaddrinfo(3) failed for git,:80
* Couldn't resolve host 'git,'
* Closing connection 1
이 BitBuckets API 문서 찾고은 400 반환 상태는 호출자가 부족한 경우 입력 문서가 유효, 또는 경우 "를 의미 타겟 계정 아래에 리포지토리를 생성 할 수있는 권한이 있습니다. " 불행히도 git-cmd.exe에서 명령을 실행하는 올바른 형식을 찾을 수 없습니다.
명령은 힘내 배쉬에서 잘 실행, 그래서 힘내 강타 과정을 실행하려고 :
var gitbashinfo = new ProcessStartInfo(@"C:\Program Files\Git\git-bash.exe");
gitbashinfo.RedirectStandardInput = true;
gitbashinfo.UseShellExecute = false;
var gitbashProcess = new Process { StartInfo = gitbashinfo };
gitbashProcess.Start();
using (StreamWriter sw = gitbashProcess.StandardInput)
{
// The command
}
gitbashProcess.WaitForExit();
을하지만,이 망할 놈의 배쉬 창을 열고, 내 명령을 실행하지 않습니다. Git-cmd.exe 프로세스에서했던 것과 똑같은 일을 솔직히 기대했습니다. 따라서 새 창을 열지 않고 이미 열려있는 창에서 모든 명령을 실행하고 결과도 함께 표시하십시오.
내 질문은 : 어떻게 내 git-cmd.exe 프로세스에서 성공적으로 실행되도록 CURL 명령을 실행할 수 있습니까? 아니면 내 프로그램 창에서 git-bash.exe 프로세스를 어떻게 실행해야합니까?
이미 이전에 시도했지만 새 창을 만듭니다. – FJPoort