I am trying to write shell script that implements FTP command reading here documents.
How do I redirect ftp command line AND results FTP server returns?
My current script is below
#!/bin/bash
ftp -ivn <<EOF |& tee ftplog.text
open <myFtpserver>
user <username> <password>
pwd
ls -l MYFILE_*
bye
EOF
This code outputs ftp server's response but ftp command to ftplog.txt. How can I redirect both?
I appreciate your help
You should create your script on this way:
#!/bin/bash
ftp -ivn >ftplog.text <<EOF
open <myFtpserver>
user <username> <password>
pwd
ls -l MYFILE_*
bye
EOF
The redirection is to the command, not inline block
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.