Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!