1+ /*****************************************************************************
2+ Copyright 2018 The TensorFlow.NET Authors. All Rights Reserved.
3+
4+ Licensed under the Apache License, Version 2.0 (the "License");
5+ you may not use this file except in compliance with the License.
6+ You may obtain a copy of the License at
7+
8+ http://www.apache.org/licenses/LICENSE-2.0
9+
10+ Unless required by applicable law or agreed to in writing, software
11+ distributed under the License is distributed on an "AS IS" BASIS,
12+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ See the License for the specific language governing permissions and
14+ limitations under the License.
15+ ******************************************************************************/
16+
117using System ;
218using System . Collections . Generic ;
319using System . Diagnostics ;
@@ -9,18 +25,30 @@ namespace Tensorflow.Util
925{
1026 public static class CmdHelper
1127 {
28+ public static void Command ( string command )
29+ {
30+ Process proc = new System . Diagnostics . Process ( ) ;
31+ proc . StartInfo . FileName = @"C:\Windows\System32\cmd.exe" ;
32+ proc . StartInfo . Arguments = "/c \" " + command + " \" " ;
33+ proc . StartInfo . UseShellExecute = false ;
34+ proc . StartInfo . RedirectStandardOutput = true ;
35+ proc . Start ( ) ;
36+
37+ while ( ! proc . StandardOutput . EndOfStream )
38+ Console . WriteLine ( proc . StandardOutput . ReadLine ( ) ) ;
39+ }
40+
1241 public static void Bash ( string command )
1342 {
14- Process proc = new System . Diagnostics . Process ( ) ;
43+ Process proc = new System . Diagnostics . Process ( ) ;
1544 proc . StartInfo . FileName = "/bin/bash" ;
1645 proc . StartInfo . Arguments = "-c \" " + command + " \" " ;
17- proc . StartInfo . UseShellExecute = false ;
46+ proc . StartInfo . UseShellExecute = false ;
1847 proc . StartInfo . RedirectStandardOutput = true ;
19- proc . Start ( ) ;
48+ proc . Start ( ) ;
2049
21- while ( ! proc . StandardOutput . EndOfStream ) {
22- Console . WriteLine ( proc . StandardOutput . ReadLine ( ) ) ;
23- }
50+ while ( ! proc . StandardOutput . EndOfStream )
51+ Console . WriteLine ( proc . StandardOutput . ReadLine ( ) ) ;
2452 }
2553 }
2654}
0 commit comments