- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: sending a mail thru automatic ftp script
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2004 01:34 AM
09-21-2004 01:34 AM
sending a mail thru automatic ftp script
I have script that is doing ftp automatically.
My concern is once the file has been ftped I need to send a confirmation mail.
if [ $? != 0 ]
then
echo "Sorry error"
else
echo "Working fine"
fi
But above checking is not working.
Anybody recommend good method of doing this.
Thanks
Vijay S
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2004 01:47 AM
09-21-2004 01:47 AM
Re: sending a mail thru automatic ftp script
I do something like this for rdist, could do the same for ftp:
( su - prdadm -c "rdist -f $DRPDIR/distfile prdadm"; ) 2>&1 |\
tee $DRPDIR/drp.log 2>&1 |\
mailx -s "prdadm DRP rdist output" `cat /usr/local/ge/mailadmin.list`
Rgds...Geoff
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2004 02:14 AM
09-21-2004 02:14 AM
Re: sending a mail thru automatic ftp script
redirecting the ftp log to another file and check for the success and use the return there.
Example:
script /tmp/ftplog.log
ftp -i -n server < inputfile
exit
# final exit
exit
--inputfile --
user root test
get /tmp/testfile
bye
---------------
We have to grep the contents on /tmp/ftplog.log file.
If you want to simply then come to rcp / scp then..
rcp remotemachine:/tmp/testfile /tmp/.
if [ $? -ne 0 ]
then
echo "Sorry error" | mail <...>
else
echo "Working fine" | mail <...>
fi
You have to setup .rhosts file.
To do more secure then go for scp there.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2004 02:30 AM
09-21-2004 02:30 AM
Re: sending a mail thru automatic ftp script
The Script is like this. What happens if the ftp ip is changed what happnes to the script. Mean the ftp IP has changed 10 days ago even though its not sending any mail that ftp has failed.
Thanks
Vijay S
#/usr/bin/sh
# This script is used to extract audit table info from AUD$ table and ftp to
# a central location.
# Server:
# Username:
# Password:
# Please format your logs like:
# For OS: servername_os_yyyymmdd.log
# For DB: servername_dbx_yyyymmdd.log
# Where for the db the x is the instance. 1 for the first, 2 for the second.
# Developed by:
# e-mail:
#
# Global env vars for this program
# User Defined Paramters
export ORACLE_SID=$1
export USER=$2
export PSWD=$3
export AUDITHOME=$4
export ORACLE_HOME=$5
NOTIFY=
NOTIFYONSUCCESS=0
AUDDATE=`date +%Y%m%d`
HOSTNM=`hostname`
FILENAME=${HOSTNM}_db_${ORACLE_SID}_${AUDDATE}.log
# Set all Oracle variables to run sqlplus
# . $HOME/.profile
export PATH=$PATH:$ORACLE_HOME:$ORACLE_HOME/bin:$ORACLE_HOME/lib
export PATH=$PATH:.
export SHLIB_PATH=$ORACLE_HOME/lib:$SHLIB_PATH
export LIBPATH=$ORACLE_HOME/lib:$LIBPATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
cd $AUDITHOME
sqlplus $USER/$PSWD @${AUDITHOME}/scripts/getauditdata.sql ${AUDITHOME}/log/${FILENAME}
if [ $? -ne 0 ]
then
mailx -s "${ORACLE_SID} Audit Extract Failed" $NOTIFY < ${AUDITHOME}/log/${FILENAME}
exit 1
fi
if [ $NOTIFYONSUCCESS = 1 ]
then
mailx -s "${ORACLE_SID} Audit Extract Successful" $NOTIFY < /dev/null
fi
ftp -v -n<< EOF
open
user
ascii
put ${AUDITHOME}/log/${FILENAME} ${FILENAME}
bye
EOF
# The code below doesn't work as expected. The above ftp command always
# returns with a code 0. Commenting this code for now
#if [ $? -ne 0 ]
#then
#echo 'removing log'
#rm ${AUDITHOME}/log/${FILENAME} ${FILENAME}
#exit 0
#fi;
# For now, I am assuming that the above ftp is always successful and
# removing the audit log
rm ${AUDITHOME}/log/${FILENAME}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2004 03:35 PM
09-21-2004 03:35 PM
Re: sending a mail thru automatic ftp script
echo '
...
ls
quit' | ftp -i $srvr | grep '^-rw-' | grep $rem_nm >> $LOG
if [ $? -eq 1 ]; then
echo "Failed"
else
echo "Succeed"
fi
The check on $? in the if looks at the status of the last grep command and not the ftp command.
Cheers
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2004 03:39 PM
09-21-2004 03:39 PM
Re: sending a mail thru automatic ftp script
And use ftp script as
ftp -v -n
open
user
ascii
put ${AUDITHOME}/log/${FILENAME} ${FILENAME}
bye
EOF
Then audit the /tmp/ftplog.log file ${FILENAME} information's and success there. And ftp return return code will be always 0 because it is ending without any problem there. So return type check after ftp completion is not worth to this.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2004 03:45 PM
09-21-2004 03:45 PM
Re: sending a mail thru automatic ftp script
machine2 <--------> machine1
$HOME/.rhosts $HOME/.rhosts
machine1 user machine2 user
So that user can be accessible between machine1, machien2 without passwd. We can check success with return type 0 there.