Shadow
Shadow4mo ago

Subprocess

can someone help me how do i get to show Hello world in my terminal by using Deno.Commands () using echo
8 Replies
NDH
NDH4mo ago
For Windows. You need to execute. echo from a command processor -- "cmd"
const command = new Deno.Command("cmd", {
args: ["/c", "echo","hello world"],
stdin: "piped",
stdout: "piped"
}).spawn();

let result = await command.output();
const textDecoder = new TextDecoder();
console.log(textDecoder.decode(result.stdout));
const command = new Deno.Command("cmd", {
args: ["/c", "echo","hello world"],
stdin: "piped",
stdout: "piped"
}).spawn();

let result = await command.output();
const textDecoder = new TextDecoder();
console.log(textDecoder.decode(result.stdout));
Shadow
Shadow4mo ago
@Altair 680b i am quite new to this . could you help me with one last doubt i have i want to npm init (for example ) in the current working directory
NDH
NDH4mo ago
FYI many linux commands are just executables. In Windows, they are methods of the command processor. I was unable to spawn 'npm' Not sure why. Try asking the #Deno AI Helper
Shadow
Shadow4mo ago
i tried using , ls , pwd in
args: ["/c", "ls"],
args: ["/c", "ls"],
'ls' is not recognized as an internal or external command, operable program or batch file. @Deno AI Helper
NDH
NDH4mo ago
Also, you may want to try DAX -- written by a Deno core team member. https://github.com/dsherret/dax
Shadow
Shadow4mo ago
Thanks alot mate
NDH
NDH4mo ago
@Deno AI Helper any help with this?
Shadow
Shadow4mo ago
ill experiment with it and if i hit a block i believe you are here for me then