Reputation: 3
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
Upvotes: 0
Views: 376
Reputation: 7225
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
Upvotes: 1