![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk not working in script | doitnow | Shell Programming and Scripting | 3 | 08-28-2008 06:36 AM |
| why the below script is not working ., | konankir | Shell Programming and Scripting | 14 | 03-27-2008 04:32 PM |
| bdf script not working !! | kpatel786 | Shell Programming and Scripting | 3 | 11-16-2007 11:10 AM |
| Pls. Help my script not working as it should | cocoabeauty1 | Shell Programming and Scripting | 1 | 07-28-2007 05:11 PM |
| FTP script not working | rookie250 | Shell Programming and Scripting | 2 | 12-19-2006 02:49 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Script not working.
Hi,
I am a DBA, worked on Windows platforms for past 6 years, and now shifted in environment where HP UX is OS environment. I have task to complete which involves Unix script to be prepared. This script should FTP the file to the destination server and if this FTP fails, then it should write in syslog file. For the same purpose, I have prepared following script. #!/usr/bin/sh # testftp : Script to transfer file from SAP to wowftp server #------------------------------------------------------------------- # Timestamp echo ------------------------------------ >> /interface/logs/alhftplog.txt echo `date` Start of FTP to WOW FTP >> /interface/logs/alhftplog.txt echo ----------------------------------- >> /interface/logs/alhftplog.txt # FTP ftp -vn HOST NAME 2> /interface/logs/ftpfailedlog.log <<END_SCRIPT >> /interface/logs/ftplog.txt quote USER USER NAME quote PASS USER PASSWORD ascii prompt off lcd /interface/outbound cd /test mput FILE PATTERN* bye END_SCRIPT # End of FTP EXITSTATUS=$? if [ $EXITSTATUS != "0" ] then logger -p local6.info -t XXTIV9999E9 "FTP to Host Failed" else echo `date` "FTP Successful" >> /interface/logs/ftplog.txt fi I am able execute above-mentioned screen and not experiencing any error. However, when I check in the system log file, no error message is being recorded. To test this problem, I have executed “logger” command from OS prompt and I have found that error is being written in the syslog file. Please help me to resolve this problem. Thanks, Best regards, Nishchal Nagre. |
|
||||
|
Hi,
My problem is, below given part of my script is not working. After execution of the script it has not spitting any error. EXITSTATUS=$? if [ $EXITSTATUS != "0" ] then logger -p local6.info -t XXTIV9999E9 "FTP to Host Failed" else echo `date` "FTP Successful" >> /interface/logs/ftplog.txt fi Thanks, Best regards, Nishchal Nagre. |
|
||||
|
I want to accomplish the same thing as Nischal, if anybody can shed light as to what's wrong with my script, I would appreciate it
![]() Here is what i want to do, ftp a file to a server then if there are any errors, an email shall be sent to my account stating that the ftp process failed. However as BubbaJoe mentioned, eventhough I get an ftp error, the return code is still zero (upon checking with $?). I need to be able to capture the error code since this will be the basis for my if statement and for the script that will run after the ftp. Initially I tried this (which didn't work): Code:
ftp -nv server.com<<-EOF user USER Password prompt ascii put testfile /export/dir/test/testfileftp bye EOF #Check if FTP is successful or not ERRCD=$? if [ $ERRCD -ne 0] then echo "The FTP process failed" | mailx -s "The FTP process failed with error code $ERRCD on $(date '+%m-%d:%H:%M')" myemail@administrator.com print “ERRCD=${ERRCD}” << /tmp/Send_errcd.log exit 1 fi Code:
ftp -nv server.com<<-EOF
user USER Password
prompt
ascii
put testfile /export/dir/test/testfileftp
bye"|ftp -iv > ftpreturn.log
EOF
#Check if FTP is successful or not
ftpresult=$?
bytesindatafile=wc -c testfile | cut -d " " -f 1
bytestransferred=grep -e '^[0-9]* bytes sent' ftpreturn.log | cut -d " " -f 1
ftptransfercomplete=grep -e '226 ' ftpreturn.log | cut -d " " -f 1
echo "-- FTP result code: $ftpresult" >> ftpreturn.log echo "-- bytes in datafile: $bytesindatafile bytes" >> ftpreturn.log echo "-- bytes transferred: $bytestransferred bytes sent" >> ftpreturn.log
if [ "$ftpresult" != "0" ] || [ "$bytestransferred" != "$bytesindatafile" ] || ["$ftptransfercomplete" != "226" ] then
echo "The CANS process failed" | mailx -s "The FTP process failed with error code $ERRCD on $(date '+%m-%d:%H:%M')" myemail@administrator.com
fi
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|