I am writing a script to automatically connect via ftp from a
CentOS-5 host to one of our older (non-*nix OS) systems. The only
common protocol that the remote host supports is ftp. What I want
to do is to capture the initial response that comes back from that
host before the user credentials are passed and log this
information.
I cannot seem to hit upon the right set of redirects to make this
happen. In my script I invoke ftp thus:
ftp -un "$TARGET_HOST" << EOS >> ${LOGGING_FILE}
2>&1
user $LOGON
dir
quit
EOS
When I connect to the host via ftp interactively from a session then
I see this:
Connected to host.domain.tld.
220 HP ARPA FTP Server [A0012H15] (C) Hewlett-Packard Co. 2000 [PASV
SUPPORT]
Remote system type is MPE/iX.
However, the first line that I find in the logging file is the
results of the dir command following the user command. Can someone
tell me how I can capture and log the initial response to the ftp
connection?
Thanks,
--
*** E-Mail is NOT a SECURE channel ***
James B. Byrne mailto:ByrneJB at Harte-Lyne.ca
Harte & Lyne Limited http://www.harte-lyne.ca
9 Brockley Drive vox: +1 905 561 1241
Hamilton, Ontario fax: +1 905 561 0757
Canada L8E 3C3
On Thu, 2 Jun 2011, James B. Byrne wrote:> tell me how I can capture and log the initial response to the ftp > connection?man expect It is usually straightforward to capture a transcript of a session, and then abstract away the needed prompts and responses (The ORA 'Exploring Expect' by Don Libes should be read and studied by every sysadmin wanting to be more than a bike-shed painter -- I use such problems to train PFY on their road to BOFH'hood) As I recall FTP has some parts in its protocol, as does telnet (another ancient protocol) that are sent to varying file handles, and with varying 'echo' to console stty options, in setting up connection options -- Russ herrold