Comments (5)
...>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.
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.
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.
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.
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)
- RunAs functionality HOT 3
- Implement `AsyncMethodBuilder` for `CommandTask<T>` to refactor some code HOT 2
- PipeTarget.ToDelegate blocks forever in StreamReader HOT 11
- Able to start process with Shell HOT 1
- Possibility to adjust ProcessStartInfo HOT 1
- Ripgrep returns exit code 1 with no stdout or stderr, can't work out why HOT 3
- Input prompt is not captured HOT 8
- Invalid encoding when running a specific executable on Windows HOT 4
- Possibility to not redirect certain process streams HOT 4
- Cannot be used in IIS? HOT 6
- Stdout and stderr order not preserved HOT 10
- Windows 11 throws exception for some arguments passed to SqlPackage HOT 6
- Support intermediate pipe handlers to transform output from one command into input for another HOT 11
- Add `WithArguments` overload (or new method) that allows appending arguments to an existing command HOT 2
- Command can deadlock if the process writes large output and one of the targets inside `PipeTarget.Merge(...)` throws
- Problem with stdOut HOT 8
- When using .NET Framework instead of .NET Core, there are problems with stdin encoding HOT 10
- UnicodeEncodeError when Python program outputs unicode HOT 4
- Allow forced argument escaping HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cliwrap.