I am trying to catch the password prompt of sftp, but somehow it is not from STDIN or STDERR. It possibly comes from a sub-process.
The following is my test. I tried to redirect the password prompt to a file. I tried file handle number 1 through 4. None worked.
mypc:/home/myname$ sftp localhost >/tmp/junk
myname@localhost's password:
mypc:/home/myname$ sftp localhost 2>/tmp/junk
myname@localhost's password:
mypc:/home/myname$ sftp localhost 3>/tmp/junk
myname@localhost's password:
mypc:/home/myname$ sftp localhost 4>/tmp/junk
myname@localhost's password:
This is my OS
mypc:/home/myname$ uname -a
Linux mypc 5.15.133.1-microsoft-standard-WSL2 #1 SMP Thu Oct 5 21:02:42 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
mypc:/home/myname$ which sftp
/usr/bin/sftp
The reason I need to catch it is because I am writing a Perl script to test sftp connection. I could have used Perl's Expect module if I were allowed to install it inside my work place.
Thank you
ssh
output to tty when both stdout and stderr are redirected?sftp
usesssh
as transport.