• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Pruebas Online
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

215
Vistas
How to run a CMD on web assembly without a server

I wanted to create a web assembly program that would enable me to execute bash commands and get output without contacting a server.

I created some rust code and did a wasm-pack compiling but it gives this error

RuntimeError: unreachable executed

My code

use std::process::Output;
use wasm_bindgen::prelude::*;
use std::process::Command;

#[wasm_bindgen]
pub fn exec(code:&str)->Vec<u8>{
    
    let output = if cfg!(target_os = "windows") {
    Command::new("cmd")
            .args(["/C", code])
            .output()
            .expect("failed to execute process")
    } else {
        Command::new("sh")
                .arg("-c")
                .arg(code)
                .output()
                .expect("failed to execute process")

    };

    output.stdout
}

^^lib.rs (used wasm-pack)

RuntimeError: unreachable executed

almost 3 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda