sftp can read commands from either standard input or from a "batch file".
For example, to get a file from the remote host, you would use the get command:
echo 'get /path/to/file' | sftp [email protected]
Or, you could use a here-document to pass the command(s) to sftp:
sftp [email protected] <<'END'
get /path/to/file
END
Or you could have the same get command in a file that you refer to with the -b command line option of sftp:
sftp -b somefile [email protected]
The file or files that you transfer to the local system would be put into the current directory (unless this is changed with lcd, "local cd", in the commands that you send to sftp).
To connect without having to give a password, arrange with public and private SSH keys as described in "How to make the script automated to take password on its own?". Note that a remote system may well have disabled SSH access for the root user (this is a sane way to configure an SSH server).
expect.