Hi everyone! I've been fighting with this problem for 2 days already...
The problem is - I can't upload a log file from my linux server. Here is the full command if I launch it from my terminal on MacOS : "scp root@*********:/root/admin/logs/logs.txt /Users/user/Desktop/". The tricky thing is that after it's launched it asks for a password from server as an input and then downloads a file. It works when I launch it from terminal. And if I try to launch my code it always says that "Permission denied, please try again." and prints it for 3 times.
How can I make it work? Do you have any ideas? Any thoughts would be greatly appreciated.
Here is my code.
use std::io::Write;
use std::process::{Command, Stdio};
fn main() {
match Command::new("scp")
.stdin(Stdio::piped())
.arg("root@********:/root/admin/logs/logs.txt")
.arg("/Users/user/Desktop/")
.spawn()
{
Ok(mut answer) => {
println!("{:?}", answer);
answer.stdin.as_mut().unwrap().write("my_password".as_bytes()).unwrap();
answer.wait().unwrap();
},
Err(error) => {
println!("{}", error)
}
}
}