linux - Is there a lower level interface than `std::process::Command` to execute a single string as a process? -


is there equivalent in rust like:

os.run("/bin/bash ln -s /dir1 /dir2"); 

i want ability spawn process using string expression similar 1 use in ptty.

the utility i've found doing std::process::command, it's not documented , seems complex , hard debug.

there in rust, how invoke system command , capture output? gives std::process::command answer, hence why specified finding possible option. however, i'm looking lower level interface make std::process::command execute single string query rather forcing me feed arguments 1 one.

no, there no such thing available in standard library. mentioned in comments, command is lower level interface. shells , other tools take single string have exceedingly clever parsing of string in order split pieces. parsing non-trivial , may differ between shells!

you can write own simplified parser, of course:

use std::process::command;  fn main() {     let args = "ls -l /etc /tmp";     let args: vec<_> = args.split(" ").collect();      let output = command::new(args[0])         .args(&args[1..])         .output()         .expect("couldn't run it");      println!("{:?}", ::std::str::from_utf8(&output.stdout));     println!("{:?}", ::std::str::from_utf8(&output.stderr)); } 

but it's not documented

i'm biased, don't understand how more documented. every useful method has prose describing , examples demonstrating it.

and seems complex

i'm not sure why; perhaps amount of choice overwhelming, realistically control needed.

and hard debug.

i'm not sure debugging needs done — either code compile or not, execute or not. compiler errors useful, runtime errors of nature depend on os.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -