Monday, September 9, 2013

How to send mail using sendmail command

Hi All,

Before doing this make sure you have installed Sendmail on your malchine.

Now here the question is how to check whether the Sendmail is installed on your machine. If you are
using Linux Environment then please use the below command to identify the Sendmail availability.
$rpm -qa | grep sendmail
if you show some output as some sendmail rpm package name then it seems like it is installed.
You can cross refer the same using below command
$man sendmail
Now all set to go...
1) Create a file as xyz.sendmail
2) open and write 'xyz@example.com' in first line of file xyz.sendmail. Now this line indicate that 'xyz@example.com' is the receiver of this mail
3) open and write 'xyz@gmail.com' in second line of file xyz.sendmail. Now this line indicate that 'xyz@gmail.com' is mark as Cc in this mail.
4) open and write any valid "Subject" you want to mention for this mail in third line of file xyz.sendmail.
5) open and write BODY or Contents of your mail from fourth line onwords of file xyz.sendmail.
6) Once done, use the command as "sendmail -t < xyz.sendmail"

Please make sure that, your machine doesn't have any open relays otherwise your system become blacklisted so that then onwords you can't drop any mails. Also your system should have a fully qualified domain name and having DNS entry. This is must since the mail is going from your machine and 'From' field in the mail should be your machine domain name.

I hope this help you while programming means sending mails through script and also an alternative for mailx command.

Thanks & Regards
Vaibhav Wadkar

How to check whether the Autosys is up or down on your machine

Hi All,

I have provided some brief introduction about Autosys in my previous post.

In this post I will discuss about how to check whether Autosys is up or down on your machine. Suppose your machine name is "example.com". If you have Linux / Unix system then try below command on your machine

$ hostname

Once you got the machine name, try to execute below commands
$chk_auto_up

This command Verifies status of the  Unicenter  AutoSys  JM Scheduler and database. It determines if the Event Server (database) and the  scheduler are running. This is the utility you can use for debugging of Autosys. The output of this command is as below.

Logon to 201.32.02.19 - example.com (XYZ)
 chk_auto_up  
______________________________________________________________________________
CAUAJM_I_50054 Attempting (1) to Connect with Database: XYZ
CAUAJM_I_50055 *** Have Connected successfully with Database: XYZ. ***
______________________________________________________________________________
CAUAJM_I_50128 Connected with Event Server: XYZ
______________________________________________________________________________
______________________________________________________________________________
CAUAJM_I_50038 Checking CA Unicenter AutoSys JM Scheduler on Machine: example.com
CAUAJM_I_50044 Primary Scheduler is RUNNING on machine: example.com
______________________________________________________________________________
There is another command too which we can use while checking whether the Autosys is up or down.
Please use the below command to test.

$autoping -m example.com -A -D

This command verifies the connectivity  of  Unicenter  AutoSys Job Management (JM) server and client machines. This command also help us in debugging of Autosys. Here option -m stands for machine name, option -A sends an alarm when if any problem is detected, option -D check  the  database connections on the specified machine. Below shows the output of the command.

$autoping -m example.com -A -D
CAUAJM_I_50023 AutoPinging Machine [example.com] 
CAUAJM_I_50028 AND checking the Agent's DB Access.
CAUAJM_I_50025 AutoPing WAS SUCCESSFUL!

These are the heavily used Autosys command while debugging Autosys command. I hope this hope will help you while fixing Autosys.

Thanks & Regards
Vaibhav Wadkar

Saturday, August 31, 2013

What is Autosys

Hi,

This post gives you very brief introduction about Autosys. I will post some more details about Autosys in upcoming posts.

What is Autosys??
Autosys is an automated job control system for scheduling, monitoring, and reporting. This is developed by Unicenter.

A job is any single command, executable, script. Each job definition contains a variety of qualifying attributes, including the conditions specifying when and where a job should be run.

Autosys uses JIL (Job Information Language) as its own language. We can use this through a command -line interface. JIL is a specification language, with its own syntax, that is used to describe when, where,and how a job should run. When you enter the jil command, you get the jil command prompt, at which you can enter the job definitions one line at a time using this special language. When you exit the jil command -line interface, the job definition is loaded into the database. Alternatively, you can enter the definition as a text file and redirect the file to the jil command. In this case, the jil command activates the language processor, interprets the information in the text file, and loads this information in the database.

Sample from unix command prompt how to use this.

echo "insert_job:      xyz
      job_type:        c
      condition:       s(xyz)
      date_conditions: y
      command:         dbconnect.ksh (you can give any script name)
      machine:         machine name on which it needs to be run" | jil

Once done the XYZ job is getting added in Autosys. You can check it the same by using the below command on unix prompt.

$autorep -J XYZ

Make sure to run all this Autosys needs to be install first on your machine

Thanks

Shell Script to execute query by connecting Database

Hi All,

This post will give some idea about how to connect Database using shell script.

I am considering here an Oracle DB since it is used most widely in the industry. Along with Oracle, SQLPLUS is installed on your system. While connecting Oracle DB as a remote machine, please make sure you have SQLPLUS installed on your machine (i.e. from where you are connecting the DB or running this script).

You can simply test whether the SQLPLUS is installed on your machine as below.

$ sqlplus
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Sep 1 07:30:12 2013
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Enter user-name:

If it is already installed then it will prompt username as above else will give you an error. Once you confirmed please try the below script (i.e. this is a sample query to show how to connect DB and execute the query)

#!/bin/ksh

#FileName: dbconnect.ksh

SQL="set feedback off underline off pages 0 lines 999 heading off
           select sysdate from dual;"

echo -e "$SQL"| sqlplus -s userid/password@TNSNAME

I have store the above script with name as dbconnect.ksh, here userid is the userid for your schema and password is the password used for the given userid. TNSNAME is nothing but the connection string you used to connect the DB.

Store the script and check if any syntx error using below command on command prompt

$ /bin/ksh -n dbconnect.ksh

Once having no error, please execute the below script by changing its permission
$chmod 775 dbconnect.ksh
$ /bin/ksh dbconnect.ksh

01-SEP-13


You can see the output as current date.

This is one of the way to execute the query, there are others ways to to connect the Database.
I hope this post is useful to you.

Thanks