Giter VIP home page Giter VIP logo

Comments (5)

Tyrrrz avatar Tyrrrz commented on August 27, 2024

...>createdbtestDump.sql is shell syntax, not a command line argument. You'd have to do Cli.Wrap(...) | PipeTarget.ToFile("createdbtestDump.sql") to achieve equivalent behavior.

Edit: sorry, didn't notice you were running exec, which I assume would probably allocate a shell under the hood.

To answer your questions:

Does it do this because the docker command returns an error, which in reality I would want to see, and

If there's an error (non-zero exit code), you'll get an exception using the code in your sample. If you don't get an exception, the process exited with 0.

Since you're running ExecuteAsync(), there is no stderr in the exception message. You're responsible for handling it yourself. However, you can replace it with ExecuteBufferedAsync() (which sounds like what you really want, based on your sample), and that will add the stderr data in your exception. That should help in debugging.

Is it that for whatever reason, it's not waiting for the docker command to finish before moving on to the next line in the batch file?

Not impossible. You could remove lines and isolate one command in your bat file to test.

from cliwrap.

samcov avatar samcov commented on August 27, 2024

You were absolutely correct, it was the ExecuteBufferedAsync() that I needed and I got the expected output.

Then I tried to do it in a real case, and I'm having trouble with the final parameters.

It can't seem to figure out the "createdbtest>createdbtestDump.sql" part. Output is: "Unknown database 'createdbtest > createdbtestdump.sql'" when selecting the database

However, if I just give it the dbname(createdbtest), it does dump it right into the console. Not where I want it, which is in the docker container.

It doesn't like redirecting the output to a file, is there something I'm missing, i.e. how to add the parameters correctly?

from cliwrap.

samcov avatar samcov commented on August 27, 2024

Additional note: This is likely where using a batch file works best.

I used a batch file and everything works as it should!

from cliwrap.

Tyrrrz avatar Tyrrrz commented on August 27, 2024

It can't seem to figure out the "createdbtest>createdbtestDump.sql" part. Output is: "Unknown database 'createdbtest > createdbtestdump.sql'" when selecting the database

Well, it does really seem like whatever docker exec is using doesn't recognize the > operator. Note that > should not be part of the command line passed to the process. It should be parsed by the shell as instructions on how to deal with the output. In CliWrap's case, CliWrap is essentially the shell and the pipes are expressed differently -- i.e., through objects instead of strings.

The correct solution depends on what you're trying to achieve. If you want to pipe the output to a local file, then use PipeTarget.ToFile(...) like I explained in the previous comment (the part that is strikethrough-ed). If you want to pipe the output to a file inside the container, then you should probably do something like dotnet exec /bin/bash -c ... so that the underlying shell (bash in this case) can parse your input and execute it properly.

from cliwrap.

samcov avatar samcov commented on August 27, 2024

Exactly, but it works a treat when I use a .bat file, and I'm sure a .sh file on linux.

Thanks a LOT!

from cliwrap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.