[process] Couple of issues

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[process] Couple of issues

Boost - Users mailing list
Hi,

I'm using boost 1.64 on Windows7 with VisualStudio 2015 64bit.
While testing boost.process I've encountered some issues that I'm not
able to resolve:

1. Passing of multiple parameters:

Consider this minimal example:

<code>
void test_sync()
{
        try
        {
                bp::ipstream is;
                bp::child c(bp::search_path("ping"), "127.0.0.1 -t", bp::std_out > is);
                std::string line;
                while (c.running() && std::getline(is, line) && !line.empty())
                {
                        std::cerr << line << std::endl;
                }
                c.wait();
        }
        catch (const std::exception& e)
        {
                std::cerr << "Error in execution: " << e.what();
        }
}
</code>

This doesn't correctly execute "ping 127.0.0.1 -t", instead it will act
like "ping 127.0.0.1". I could not find an up2date example on how to
pass parameters correctly. Any ideas?

2. No output on std::cout
It seems that some applications don't output to std::cout/clog/cerr but
somehow via printing to console directly (my guess as it is colored
output on windows)
In those instances, redirection fails. Can anyone think of a way to
still monitor the output of the spawned child?

Cheers
Sebastian


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [process] Couple of issues

Boost - Users mailing list
Hi,

1. Use "bp::child c(bp::search_path("ping"), "127.0.0.1", "-t", bp::std_out > is);"
2. I'm on Windows, Boost 1.66, VS2017 and output is generated. (With your original code: "Ping request could not find host 127.0.0.1 -t. Please check the name and try again.")

J

2018-01-02 10:15 GMT+01:00 Sebastian Messerschmidt via Boost-users <[hidden email]>:
Hi,

I'm using boost 1.64 on Windows7 with VisualStudio 2015 64bit.
While testing boost.process I've encountered some issues that I'm not able to resolve:

1. Passing of multiple parameters:

Consider this minimal example:

<code>
void test_sync()
{
        try
        {
                bp::ipstream is;
                bp::child c(bp::search_path("ping"), "127.0.0.1 -t", bp::std_out > is);
                std::string line;
                while (c.running() && std::getline(is, line) && !line.empty())
                {
                        std::cerr << line << std::endl;
                }
                c.wait();
        }
        catch (const std::exception& e)
        {
                std::cerr << "Error in execution: " << e.what();
        }
}
</code>

This doesn't correctly execute "ping 127.0.0.1 -t", instead it will act like "ping 127.0.0.1". I could not find an up2date example on how to pass parameters correctly. Any ideas?

2. No output on std::cout
It seems that some applications don't output to std::cout/clog/cerr but somehow via printing to console directly (my guess as it is colored output on windows)
In those instances, redirection fails. Can anyone think of a way to still monitor the output of the spawned child?

Cheers
Sebastian


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [process] Couple of issues

Boost - Users mailing list


Am 02.01.2018 um 10:58 schrieb JF via Boost-users:
> Hi,
>
> 1. Use "bp::child c(bp::search_path("ping"), "127.0.0.1", "-t",
> bp::std_out > is);"

ok, that works. Thanks.
But how to pass a list of parameters? (e.g. obtained from a command line).

> 2. I'm on Windows, Boost 1.66, VS2017 and output is generated. (With
> your original code: "Ping request could not find host 127.0.0.1 -t.
> Please check the name and try again.")

I've explicitly stated "some applications" ;-) There are certain
programs that seem to behave differently.


Cheers
Sebastian

>
> J
>
> 2018-01-02 10:15 GMT+01:00 Sebastian Messerschmidt via Boost-users
> <[hidden email] <mailto:[hidden email]>>:
>
>     Hi,
>
>     I'm using boost 1.64 on Windows7 with VisualStudio 2015 64bit.
>     While testing boost.process I've encountered some issues that I'm
>     not able to resolve:
>
>     1. Passing of multiple parameters:
>
>     Consider this minimal example:
>
>     <code>
>     void test_sync()
>     {
>              try
>              {
>                      bp::ipstream is;
>                      bp::child c(bp::search_path("ping"), "127.0.0.1
>     -t", bp::std_out > is);
>                      std::string line;
>                      while (c.running() && std::getline(is, line) &&
>     !line.empty())
>                      {
>                              std::cerr << line << std::endl;
>                      }
>                      c.wait();
>              }
>              catch (const std::exception& e)
>              {
>                      std::cerr << "Error in execution: " << e.what();
>              }
>     }
>     </code>
>
>     This doesn't correctly execute "ping 127.0.0.1 -t", instead it will
>     act like "ping 127.0.0.1". I could not find an up2date example on
>     how to pass parameters correctly. Any ideas?
>
>     2. No output on std::cout
>     It seems that some applications don't output to std::cout/clog/cerr
>     but somehow via printing to console directly (my guess as it is
>     colored output on windows)
>     In those instances, redirection fails. Can anyone think of a way to
>     still monitor the output of the spawned child?
>
>     Cheers
>     Sebastian
>
>
>     _______________________________________________
>     Boost-users mailing list
>     [hidden email] <mailto:[hidden email]>
>     https://lists.boost.org/mailman/listinfo.cgi/boost-users
>     <https://lists.boost.org/mailman/listinfo.cgi/boost-users>
>
>
>
>
> _______________________________________________
> Boost-users mailing list
> [hidden email]
> https://lists.boost.org/mailman/listinfo.cgi/boost-users
>
_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: [process] Couple of issues

Boost - Users mailing list
Something like this works for me:

...
std::vector<std::string> args;

args.push_back("127.0.0.1");
args.push_back("-t");

bp::ipstream is;
bp::child c(bp::search_path("ping"), args, bp::std_out > is);
...

J

2018-01-02 11:59 GMT+01:00 Sebastian Messerschmidt via Boost-users <[hidden email]>:


Am 02.01.2018 um 10:58 schrieb JF via Boost-users:
Hi,

1. Use "bp::child c(bp::search_path("ping"), "127.0.0.1", "-t", bp::std_out > is);"

ok, that works. Thanks.
But how to pass a list of parameters? (e.g. obtained from a command line).

2. I'm on Windows, Boost 1.66, VS2017 and output is generated. (With your original code: "Ping request could not find host 127.0.0.1 -t. Please check the name and try again.")

I've explicitly stated "some applications" ;-) There are certain programs that seem to behave differently.


Cheers
Sebastian

J

2018-01-02 10:15 GMT+01:00 Sebastian Messerschmidt via Boost-users <[hidden email] <mailto:[hidden email]>>:

    Hi,

    I'm using boost 1.64 on Windows7 with VisualStudio 2015 64bit.
    While testing boost.process I've encountered some issues that I'm
    not able to resolve:

    1. Passing of multiple parameters:

    Consider this minimal example:

    <code>
    void test_sync()
    {
             try
             {
                     bp::ipstream is;
                     bp::child c(bp::search_path("ping"), "127.0.0.1
    -t", bp::std_out > is);
                     std::string line;
                     while (c.running() && std::getline(is, line) &&
    !line.empty())
                     {
                             std::cerr << line << std::endl;
                     }
                     c.wait();
             }
             catch (const std::exception& e)
             {
                     std::cerr << "Error in execution: " << e.what();
             }
    }
    </code>

    This doesn't correctly execute "ping 127.0.0.1 -t", instead it will
    act like "ping 127.0.0.1". I could not find an up2date example on
    how to pass parameters correctly. Any ideas?

    2. No output on std::cout
    It seems that some applications don't output to std::cout/clog/cerr
    but somehow via printing to console directly (my guess as it is
    colored output on windows)
    In those instances, redirection fails. Can anyone think of a way to
    still monitor the output of the spawned child?

    Cheers
    Sebastian


    _______________________________________________
    Boost-users mailing list
    [hidden email] <mailto:[hidden email]>
    https://lists.boost.org/mailman/listinfo.cgi/boost-users
    <https://lists.boost.org/mailman/listinfo.cgi/boost-users>




_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users