Wednesday, February 17, 2010

FTP automation on Windows and Unix

Automation is one thing that I like the most, it makes my job easier on a daily basis - makes you sit back and relax and sprawl whilst a critical task is being completed by the script but in the long run the same script would be more than sufficient to get me fired out of my Organization since every thing is taken care by the machine against man - let me not sound more or less like a Cyborg from a James Cameron's famous movie ;-).


Here are two scripts that would enlable you to automate an FTP process from a source host to a destination.



###############
## U N I X  ###
###############

##########################
### FTP_Automation.ksh ###
##########################
#!/usr/bin/ksh

if [ "$#" -ne 3 ]
then
echo " USAGE: "
echo " ------ "
echo "\n"
echo " ksh FTP_Automation.ksh TARGET_HOST_OR_IP PASSWORD_OF_USERNAME USERNAME"
echo "\n"
echo " Examples : "
echo " ---------- "
echo "\n"
echo " ksh FTP_Automation.ksh unix_host_2 manager oracle"
echo "\n"
echo " ksh FTP_Automation.ksh 10.10.11.12 manager oracle"
echo "\n"
exit 1
fi

export target_host=$1
export username=$3
export password=2
ftp -niv << E_O_F
open $target_host
user $username $password
hash
bin
cd $HOME/unix2
put $HOME/unix1/file1
put $HOME/unix1/file2
put $HOME/unix1/file3
bye
E_O_F


#### The files are being copied from $HOME/unix1 directory
#### on unix_host_1 host (server) to $HOME/unix2 directory
#### on unix_host_2 host (server).


#### The files will be copied to $HOME/unix2 directory
#### Please change the locations and the file names in the 
#### script if you want the files to be copied to some other 
#### location.


###########
## E N D ##
###########




unix_host_1:$> ksh FTP_Automation.ksh 10.10.11.12 pass root





#####################
## W I N D O W S  ###
#####################

##########################
### FTP_Automation.txt ###
##########################

user user_name
pass_word
bin
hash
put "C:\Documents and Settings\oracle_and_unix\Desktop\file1.txt"
put "C:\Documents and Settings\oracle_and_unix\Desktop\file2.txt"
bye

#########
# E N D #
#########




##########################
### FTP_Automation.bat ###
##########################

ftp -n -s:C:\Documents and Settings\oracle_and_unix\Desktop\FTP_Automation.txt 10.10.11.12

#########
# E N D #
#########


The batch file FTP_Automation.bat implicitly calls the FTP_Automation.txt, the batch file (FTP_Automation.bat) can be scheduled in Scheduled Tasks of 'Control Panel' or simply run from the command prompt or even a double click on the batch file would inititate the ftp copy of files.

Wednesday, February 3, 2010

ORA-01801: date format is too long for internal buffer



Target type=Agent 
Host=UNIX 
Occurred At=Feb 29, 2008 6:19:17 AM EST 
Message=25 successive severity upload requests have failed. Last 
severity upload error is ORA-01801: date format is too long for internal buffer 
Metric=Consecutive severity upload failure count 
Metric value=25 
Severity=Critical 
Acknowledged=No 
Notification Rule Name=Misconfigured agents 
Notification Rule Owner=SYSMAN 



This is an out of the blue error that any environment would throw out as
part of the daily monitoring using OEM GC. This usually crops up from the
target host where the OEM agent takes care of the job of monitoring the
host and its instances and other processes. Any DBA out of his/her
instinctive efforts would try to bounce the agent thinking the agent has
gone crazy after having run for so many days or may be so many months.
But with an ./emctl upload from the AGENT_HOME/bin shows up
the same error again.

Some folks even try to bounce the OEM console giving it a vain attempt to
resolve the issue but to no avail. However the actual trick is to bounce
the OEM repository database along with the OEM console, to work around the
situation. The order of bounce to be followed is shown below.



Shutdown Order
--------------

OEM GC --> OEM Repository DB

OMS_HOME/opmn/bin/opmnctl stopall

ORACLE_HOME/bin/lsnrctl stop LISTENER

ORACLE_HOME/bin/dbshut


Startup Order
-------------

OEM Repository DB --> OEM GC

ORACLE_HOME/bin/dbstart

ORACLE_HOME/bin/lsnrctl start LISTENER

OMS_HOME/opmn/bin/opmnctl startall