Coder Social home page Coder Social logo

Comments (5)

sagiegurari avatar sagiegurari commented on July 24, 2024

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.

JonahPlusPlus avatar JonahPlusPlus commented on July 24, 2024

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.

sagiegurari avatar sagiegurari commented on July 24, 2024

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.

JonahPlusPlus avatar JonahPlusPlus commented on July 24, 2024

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.

sagiegurari avatar sagiegurari commented on July 24, 2024

ok got it :)
happy you have a working solution.

from duckscript.

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.