Reason for using file descriptors Associated with stdin Instead of using stdin directly?

I have a bashscript that runs scpas follows:

echo "${SCP_PASS:-$PASSWORD}" | ( exec 3<&0; scp -qp ${SCP_PORT:+-P$SCP_PORT} -oStrictHostKeyChecking=yes -oPasswordFd=3 $TRANSFER_FILE "$SCP_USER@$SCP_HOST:$SCP_PATH" )

What is the point exec 3<&0? As I understand it, it copies the handle stdinto the file 3. Why is this necessary? Why not use -oPasswordFd=0?

+4
source share
1 answer

stdin fd 3 - PasswordFd, , openssh - , scp, , , , stdin , btw openssh scp

+3

Source: https://habr.com/ru/post/1652021/


All Articles