1834187 Members
2460 Online
110064 Solutions
New Discussion

My script

 
Martyn Foster
Occasional Contributor

My script

Hi All,

I have this script below (getaudit):-
# Requires file Hostnames.txt in the local directory. This file contains
# a list of system hostnames, one to a line.
#
if [ -f Hostnames.txt ]
then for host in `cat Hostnames.txt`
do ftp -n $host <<@END
user ******* ********
cd /tmp
asc
get audit
@END
echo $host
mv audit $host.audit
done
else echo $0: Cannot find Hostnames.txt
fi

Basically it collects a system audit file from each system in hostnames.txt and I would like to get more clear output/error messages from it. When it works, it echoes back the hostname but when it fails i don't get much information. I would like the output to look something like:-

Start of audot for
.
.
.
End of audit for

It's just to better understand the output when it scrolls down the screen, any help would be gratefully received.

Kind Regards,

Martyn
Tough times don't last, tough people do!
3 REPLIES 3
Robin Wakefield
Honored Contributor

Re: My script

Hi Martyn,

On your ftp command line, append as follows:
ftp -n $host < ftp.check.log 2> ftp.check.err
...
...
!

then you can interrogate the log and err files for detailed analysis after each ftp command.

Rgds, Robin
Praveen Bezawada
Respected Contributor

Re: My script

Hi
You can write the stderr into file by saying
2>err.lst

ex:-
ls 2>err.lst write the errors generated by the command into the err.lst file
You can do something like that for all the commands where you want to capture the error messages.

...BPK...
Joseph Chakkery
Valued Contributor

Re: My script

Hi martyn,

Try the following, it may help u.FTPLOG=/tmp/ftplog
if [ -f host.name ]
then
for hostname in `cat host.name`
do
ftp -n $hostname < user ******* *******
cd /etc
ascii
get hosts
bye
EOF
echo $hostname
mv hosts $hostname.hosts
done 1>$FTPLOG 2>&1
else
echo "File name doesn't exists" >>$FTPLOG
fi

Regards
Joe.

Knowledge is wealth