Я хотел бы задать несколько вопросов:
• Как выполнить команду "C: \ strawberry \ perl \ bin \ perl.exe C: \ temp \ bin \ mactime.pl -b C: \ temp \ bin \ testing.bodyfile -z UCT-8> C: \ temp \ bin \ testing2.txt "в консольной программе C #?
• Как отобразить результаты консоли?Должен ли я использовать "console.writeline"?
Mactime.pl из окон "Sleuth Kit".
Команда отлично работает в обычной командной строке.Консольная программа C # выполняется с ошибками:
"Невозможно открыть C: \ temp \ bin \ testing.bodyfile -z UCT-8> C: \ temp \ bin \ testing2.txt в C: \temp \ bin \ mactime.pl строка 282. "
и не отображает никаких результатов.После выполнения программы не генерируется «testing2.txt».
Ниже приведены мои коды:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Win32;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
LaunchCommandLineApp();
}
static void LaunchCommandLineApp()
{
// For the example
const string ex1 = "C:\\temp\\bin\\mactime.pl";
const string ex2 = "C:\\temp\\bin\\testing.bodyfile";
const string ex3 = "C:\\temp\\bin\\testing2.txt";
// Use ProcessStartInfo class
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.FileName = "C:\\strawberry\\perl\\bin\\perl.exe";
startInfo.WindowStyle = ProcessWindowStyle.Hidden;
startInfo.Arguments = "\"" + ex1 + "\" -b " + ex2 + "\" -z UCT-8 >" + ex3;
try
{
// Start the process with the info we specified.
// Call WaitForExit and then the using statement will close.
using (Process exeProcess = Process.Start(startInfo))
{
exeProcess.WaitForExit();
}
}
catch
{
// Log error.
}
}
}
}
Mactime.pl Аргументы:
mactime [-b body_file] [-p пароль_файла] [-g group_file] [-i день | часовой idx_file] [-d] [-h] [-V] [-y] [-z TIME_ZONE] [ДАТА] -b: указываетрасположение файла тела, иначе используется STDIN -d: выводить временную шкалу и индексный файл в формате с разделителями-запятыми -h: отображать заголовок с информацией о сеансе -i [день |час] файл: Указывает индексный файл со сводкой результатов
-g: Specifies the group file location, else GIDs are used
-p: Specifies the password file location, else UIDs are used
-V: Prints the version to STDOUT
-y: Dates have year first (yyyy/mm/dd) instead of (mm/dd/yyyy)
-m: Dates have month as number instead of word (can be used with -y)
-z: Specify the timezone the data came from (in the local system format)
[DATE]: starting date (yyyy-mm-dd) or range (yyyy-mm-dd..yyyy-mm-dd)