You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to read any file from the VM? I tried to use cat via the run function but the run function does only return the exit code (I assume). I see that the output is logged to the console but it would be great to have a callback for the output as well.
The text was updated successfully, but these errors were encountered:
For the time being, you can capture console output (i.e. both stdout and stderr) with the following snippet. This works by capturing all output into an array bufs whilst the command runs, and then clearing it when it finishes.
constcx=awaitCheerpXApp.create(/* ... */);constdecoder=newTextDecoder("utf-8");letbufs=[];constwriteCharCode=cx.setCustomConsole(buf=>bufs.push(buf),60,30);asyncfunctionrun(command,args,opts){constcode=awaitcx.run(command,args,opts);constoutput=bufs.map(buf=>decoder.decode(buf)).join("");bufs=[];return{ code, output };}// Run cat and capture its outputconstcat=awaitrun("/bin/cat",["/etc/hosts"],{env: ["HOME=/home/user","TERM=xterm","USER=user","SHELL=/bin/bash","EDITOR=vim","LANG=en_US.UTF-8","LC_ALL=C"],cwd: "/",uid: 1000,gid: 1000,});console.log("cat exited with code:",cat.code);console.log("cat output:",cat.output);
Is it possible to read any file from the VM? I tried to use
cat
via therun
function but the run function does only return the exit code (I assume). I see that the output is logged to the console but it would be great to have a callback for the output as well.The text was updated successfully, but these errors were encountered: