What does the -b option do in SFTP What does the -b option do in SFTP unix unix

What does the -b option do in SFTP


/dev/fd isn't actually the floppy drive -- "fd" stands for "file descriptor." Try man fd in a terminal.

This page gives an overview of what's going on: http://lists.apple.com/archives/darwinos-users/2004/Apr/msg00042.html. Basically, the first file SFTP writes to (perhaps the file it downloads?) is being passed back into itself as the batch file.

Without seeing the whole script or knowing SFTP's internals, I can't tell exactly what's going on. I'd guess that there's a list of files on the server the script connects to, and /dev/fd/3 is used to get SFTP to download the list and then download the files without reconnecting.


The "/dev/fd*" files are special devices. These aren't really taking up that much space on your system. They allow a process to access file descriptors by number; 0,1,2 are standard input, standard output and standard error, and other open files start with 3

In your case sftp using -b to read command from /dev/fd/3

Example:

[root@04 fd]# exec 3< /etc/resolv.conf[root@04 fd]# cat /dev/fd/3search example.com nameserver 10.10.10.10nameserver 20.20.20.20

You can read data using read command

[root@04 fd]# read -u 3 a b[root@04 fd]# echo $a $bnameserver 10.10.10.10

output of /dev/fd directoy

[root@04 fd]# ls -l /dev/fd/total 0lrwx------ 1 root root 64 Feb 20 14:34 0 -> /dev/pts/0lrwx------ 1 root root 64 Feb 20 14:34 1 -> /dev/pts/0lrwx------ 1 root root 64 Feb 20 14:34 2 -> /dev/pts/0lr-x------ 1 root root 64 Feb 20 14:34 3 -> /etc/resolv.conf

Notes: In your case that input file could be different