Comments (5)
if you want the output, you need to define an output var and use the stdout sub var.
from: https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#std__process__Execute
output = exec ls
echo ${output.stdout}
echo ${output.stderr}
echo ${output.code}
however, if you want the list of files in a path as an array, why not use 'ls' command:
https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#std__fs__List
or if you want a glob, you can use:
https://github.com/sagiegurari/duckscript/blob/master/docs/sdk.md#std__fs__GlobArray
from duckscript.
exec ls
is not cross-platform. For me, duckscript tries to run it in what I'm guessing is cmd.exe. Since cmd.exe does not have the ls command, it fails.
I want the list of files in a path as an array, but ls returns a bool, not a handle? I want to be able to capture the output that gets sent to the stdout of my terminal, but there seems to be no way of doing that in duckscript, at least documented.
GlobArray seems to be what I want, thanks. You might want to put a notice of this under ls, since in other script languages, ls is what I would turn to first for something simple as just getting all the files in a directory.
from duckscript.
no, there is ls command in duckscript without exec. its built in and returns a list.
did you look at the link i wrote?
from duckscript.
Yeah, first, I should clarify, each paragraph I wrote referred to each of your solutions. Your first solution (exec) didn't work cause it looks for ls on the system, not the one provided. The second solution (the link to the built-in ls), doesn't work for me since it just returns true or false when I need the output of it which just prints to the terminal. I can't get stdout or an array from it.
The third solution works, it's what I expect ls to act like (returning an array of paths).
from duckscript.
ok got it :)
happy you have a working solution.
from duckscript.
Related Issues (20)
- Feature Request - echo Colored Text HOT 6
- Command to get file size HOT 1
- Zip/unzip command HOT 6
- --recursive flag for some `fs` commands HOT 8
- Using multiple backslashes results in only a single one HOT 4
- Embed Examples HOT 2
- Passing stdin with exec HOT 4
- Upgrade regex package versions to >=1.5.5 (security vulnerabilities) HOT 1
- Newline Escapes HOT 3
- AUR package for duckscript HOT 2
- glob follows symlinks recursively HOT 3
- mv file.rs new_file.rs does not work HOT 5
- Confusion about condition statement HOT 6
- public new release after security fix from ftp crate
- Support array spread in exec HOT 7
- How to change a directory's name HOT 4
- `replace` can not accept a unicode character like \u{FEFF} HOT 1
- `if eq` does not support empty strings HOT 2
- WebAssembly 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 duckscript.