Operating System - HP-UX
1832920 Members
2791 Online
110048 Solutions
New Discussion

Re: Recording ftp sessions

 
SOLVED
Go to solution
Dermot Beirne
Frequent Advisor

Recording ftp sessions

I am running a script that ftp's files to another server. I am using a hp9000 running hpux 10.20.
I want to record all the individual files being ftp'd.
I am using a "mput p*" line in the script to send all the files, but even redirecting stdout and stderr does not show the detailed output I need, as shown here:

200 PORT command successful.
150 Opening BINARY mode data connection for test.
226 Transfer complete.
228 bytes sent in 0.02 seconds (14.64 Kbytes/s)

How can I get the script to record this detail.
Thanks.
Dermot
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.
5 REPLIES 5
James R. Ferguson
Acclaimed Contributor
Solution

Re: Recording ftp sessions

Dermot:

Add the '-v' option and do something like this:

{ echo "open thehost
user uuu ppp
hash
mput *
close"
} | ftp -i -n -v 2>&1 | tee /tmp/ftplog.$$

...JRF...
Stefan Farrelly
Honored Contributor

Re: Recording ftp sessions


You need to use the -v option on ftp.

Or, change the following line in /etc/inetd.conf

ftp stream tcp nowait root /usr/lbin/ftpd ftpd -v -L

By adding on the -v and -L, now whenever files are ftp'd to or from your server all the details are logged to /var/adm/syslog/syslog.log - including the filenames.
Im from Palmerston North, New Zealand, but somehow ended up in London...
Dermot Beirne
Frequent Advisor

Re: Recording ftp sessions

Thanks for the quick response guys, it worked a treat!

By the way, can you tell me what the difference between

ftp -i -n -v 1>>/tmp/ftpd1.err 2>>/tmp/ftpd2.err

and

ftp -i -n -v 2>&1 | tee /tmp/ftplog.err

is?
The information recorded in my ftpd1.err file
and ftplog.err seems identical? What does the
tee and &1 do?
thanks
Dermot
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.
Stefan Farrelly
Honored Contributor

Re: Recording ftp sessions


In the first example all output from the ftp goes to file ftpd1.err and any errors go to file ftpd2.err (none on your screen). In the 2nd example all output and errors go to the same place (the "2>&1") which will be on your screen, then the tee command means make a copy of all the output and errors to a file called ftplog.err
Im from Palmerston North, New Zealand, but somehow ended up in London...
Dermot Beirne
Frequent Advisor

Re: Recording ftp sessions

Thanks to you all for your help, I'm working away perfectly now.

Bye,
Dermot
Happy is harder than money. Anyone who thinks money will make them happy, doesn't have money.