24 lines
725 B
Rust
24 lines
725 B
Rust
use fake_sftp::packet::dispatch_packet;
|
|
|
|
use std::io::{BufWriter, Write};
|
|
use std::process::Command;
|
|
|
|
fn main() {
|
|
eprintln!("{}", execute_php("echo \"hola rusty mundo\";"));
|
|
loop {
|
|
let packet = fake_sftp::packet::Packet::read_packet();
|
|
dispatch_packet(packet)
|
|
}
|
|
}
|
|
|
|
fn execute_php(command: &str) -> String {
|
|
let output = Command::new("php")
|
|
.args(&["-r", command])
|
|
.output()
|
|
.expect("");
|
|
let mut buff_stderr = BufWriter::new(std::io::stderr());
|
|
buff_stderr.write(&output.stderr).expect("Unable to write to stderr.");
|
|
buff_stderr.flush().expect("Unable to flush stderr.");
|
|
return String::from_utf8(output.stdout).expect("Unable to parse php response");
|
|
}
|