2003-12-16 00:30:46 +03:00
|
|
|
/*=========================================================================
|
|
|
|
|
|
|
|
Program: KWSys - Kitware System Library
|
|
|
|
Module: $RCSfile$
|
|
|
|
|
|
|
|
Copyright (c) Kitware, Inc., Insight Consortium. All rights reserved.
|
|
|
|
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even
|
|
|
|
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
|
|
PURPOSE. See the above copyright notices for more information.
|
|
|
|
|
|
|
|
=========================================================================*/
|
2003-05-08 22:17:26 +04:00
|
|
|
#include <kwsys/Directory.hxx>
|
2003-06-10 23:50:45 +04:00
|
|
|
#include <kwsys/Process.h>
|
2003-12-23 19:03:33 +03:00
|
|
|
#include <kwsys/ios/iostream>
|
2003-05-08 22:17:26 +04:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
kwsys::Directory();
|
2003-06-10 23:50:45 +04:00
|
|
|
kwsysProcess* kp = kwsysProcess_New();
|
|
|
|
const char* cmd[] = {"echo", "Hello, World!", 0};
|
|
|
|
kwsysProcess_SetCommand(kp, cmd);
|
|
|
|
kwsysProcess_Execute(kp);
|
|
|
|
char* data = 0;
|
|
|
|
int length = 0;
|
2003-12-05 19:53:17 +03:00
|
|
|
while(kwsysProcess_WaitForData(kp, &data, &length, 0))
|
2003-06-10 23:50:45 +04:00
|
|
|
{
|
2003-12-23 19:03:33 +03:00
|
|
|
kwsys_ios::cout.write(data, length);
|
2003-06-10 23:50:45 +04:00
|
|
|
}
|
2003-12-31 00:23:16 +03:00
|
|
|
kwsysProcess_WaitForExit(kp, 0);
|
|
|
|
if(kwsysProcess_GetState(kp) == kwsysProcess_State_Error)
|
|
|
|
{
|
|
|
|
kwsys_ios::cout << kwsysProcess_GetErrorString(kp) << kwsys_ios::endl;
|
|
|
|
}
|
|
|
|
else if(kwsysProcess_GetState(kp) == kwsysProcess_State_Exception)
|
|
|
|
{
|
|
|
|
kwsys_ios::cout << kwsysProcess_GetExceptionString(kp) << kwsys_ios::endl;
|
|
|
|
}
|
2003-06-10 23:50:45 +04:00
|
|
|
kwsysProcess_Delete(kp);
|
2003-12-23 19:03:33 +03:00
|
|
|
kwsys_ios::cout << kwsys_ios::endl;
|
2003-05-08 22:17:26 +04:00
|
|
|
return 0;
|
|
|
|
}
|