I am currently working on a C++ program that invokes Dropbear SCP and redirects the progress to a log file using dup2. Here is the relevant code snippet:
int fd = open(logfile, O_CREAT | O_WRONLY, 0600);
dup2(fd, 1);
dup2(fd, 2);
close(fd);
/* Execute the SCP command: "scp -v <src> <dest>" env: "DROPBEAR_PASSWORD=<pass>" */
execvpe(cmd, argv, envp);
We use Dropbear v2022.82. The transfer is successful, and the log file contains the following:
Executing: program /usr/bin/dbclient host <ip>, user <usr>, command scp -v -f <file>
/usr/bin/dbclient:
scp: debug1: fd 3 clearing O_NONBLOCK
Sink: C0644 50339840 <file>
Sending file modes: C0644 <size> <file>
I have a few questions:
Currently, I rely on searching for the string "Sending file modes" in the log file to determine when the transfer starts. Are there better methods to identify when the transfer has started more effectively?
The "-f" option, which runs the SCP command in the background, is automatically added. Is there a way to remove this option and run SCP in the foreground, enabling me to determine when the transfer has completed?
While inspecting the log file, I notice that the progress updates I expect are missing, and I only encounter the message "scp: debug1: fd 3 clearing O_NONBLOCK". Is there a way to capture the progress updates in the log file?
Many thanks!