FakeSFTP/src/main.rs

24 lines
725 B
Rust
Raw Normal View History

use fake_sftp::packet::dispatch_packet;
2020-11-06 21:12:33 +01:00
use std::io::{BufWriter, Write};
2020-11-06 15:21:46 +01:00
use std::process::Command;
fn main() {
eprintln!("{}", execute_php("echo \"hola rusty mundo\";"));
loop {
let packet = fake_sftp::packet::Packet::read_packet();
2020-11-06 15:21:46 +01:00
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());
2020-11-06 21:12:33 +01:00
buff_stderr.write(&output.stderr).expect("Unable to write to stderr.");
buff_stderr.flush().expect("Unable to flush stderr.");
2020-11-06 15:21:46 +01:00
return String::from_utf8(output.stdout).expect("Unable to parse php response");
}