Sponsored Content
Full Discussion: Script need to get fixed
Top Forums Shell Programming and Scripting Script need to get fixed Post 302482212 by asifrafiqe on Tuesday 21st of December 2010 12:18:35 AM
Old 12-21-2010
i am thankful to all of my friends here is the script whicih ii finally figure out and it worked for me
Code:
#!/usr/bin/ksh
. ${HOME}/.profile
. /data01/dsproject/vdw/include/include_001.ksh
INC001_SET_ENV admin
SCRIPTNAME=pwd_expire.ksh
TOOL=bteq
LOGFILE=${LOGDIR}/${SCRIPTNAME%.*}.log
echo "${DATE} ${TIME} START - \"${SCRIPTNAME}\"\n"      > ${LOGFILE}
##########################################################################
#
##########################################################################
DO_PWD_CHECK()
{
#echo $*
while [ "$#" -gt "0" ] ; do
  APPL=$1
  ITAM_MAIL=$2
  rm -rf ${FILEDIR}/${APPL}_pwd_expire.log
  ${TOOL} <<- EOF >> ${LOGFILE} 2>&1
  .RUN FILE=${BASEDIR}/.dbadmin
  .SET ERROROUT STDOUT
  .EXPORT REPORT FILE=${FILEDIR}/${APPL}_pwd_expire.log
  .SET WIDTH 200
  SET SESSION DATEFORM=ANSIDATE;
 
SELECT 
   a.DatabaseName,
            
   ((100 * ((4 * NULLIFZERO(a.PasswordChgDate) - 1) / 146097)
   + (4 * (((4 * a.PasswordChgDate - 1) MOD 146097) / 4)
   + 3) / 1461 - 1900) + ((5 * (((4 * (((4 * a.PasswordChgDate
   - 1) MOD 146097) / 4) + 3) MOD 1461 + 4) / 4) - 3) / 153 + 2)
   / 12) * 10000 + (((5 * (((4 * (((4 * a.PasswordChgDate - 1)
   MOD 146097) / 4) + 3) MOD 1461 + 4) / 4) - 3) / 153 + 2) MOD 12
   + 1) * 100 + ((5 * (((4 * (((4 * a.PasswordChgDate - 1) MOD
   146097) / 4) + 3) MOD 1461 + 4) / 4) - 3) MOD 153 +5) / 5
   (DATE, FORMAT 'yy/mm/dd', NAMED PasswdChgDate),
  
            b.expirepassword ,
            Passwdchgdate + COALESCE(b.expirepassword,90) AS "NextChgDate",
            COALESCE(a.Profilename,'NOT ASSIGNED') AS Profilename,
            a.commentstring
  FROM dbc.DBASE a LEFT JOIN dbc.profileinfo b ON a.profilename = b.profilename
  WHERE  COALESCE(a.commentstring,'NOCMT') <> 'Not Used'
  AND a.Passwordchgdate >= 0
  --AND  ( DATE + 30 > NextChgDate )
  AND NextChgDate BETWEEN DATE AND DATE + 30
  ORDER BY 5,1;
 
SELECT 
   a.DatabaseName,            
   'User need to change initial password' as Reason,
            b.expirepassword ,
            -- a.Passwordchgdate + COALESCE(b.expirepassword,90) AS "NextChgDate",
            COALESCE(a.Profilename,'NOT ASSIGNED') AS Profilename,
            a.commentstring
  FROM dbc.DBASE a LEFT JOIN dbc.profileinfo b ON a.profilename = b.profilename
  WHERE  COALESCE(a.commentstring,'NOCMT') <> 'Not Used'
  AND a.Passwordchgdate < 0
  --AND  ( DATE + 30 > NextChgDate )
  ORDER BY 5,1;
 
  .IF ERRORCODE != 0 THEN .EXIT ERRORCODE
  .LOGOFF
  .EXIT 0
EOF
  RC=$?
  if [ "${RC}" != "0" ] ; then
    echo "Error: ${SCRIPTNAME} exited with RC=${RC}" > ${MAIL_HEADER}
    mail -s ${SCRIPTNAME} -a ${LOGFILE} ${MAIL_ADDR} < ${MAIL_HEADER}
    exit 1
  elif [ -f "${FILEDIR}/${APPL}_pwd_expire.log" ] ; then
    echo "${APPL}, password expire" > ${MAIL_HEADER}
    mail -s ${SCRIPTNAME} -a ${FILEDIR}/${APPL}_pwd_expire.log ${ITAM_MAIL} < ${MAIL_HEADER}
  fi
  shift 2
done
return
}
########################################################################
#
########################################################################
DO_PWD_CHECK QW_applications ${QW_ITAM_MAIL_ADDR} DRO_applications ${DRO_ITAM_MAIL_ADDR} BASE ${MAIL_ADDR} 
echo "\n"                                               >> ${LOGFILE}
echo "${DATE} ${TIME} STOP  - \"${SCRIPTNAME}"\"        >> ${LOGFILE}
exit 0


Last edited by Franklin52; 12-21-2010 at 07:44 AM.. Reason: Please use code tags, thank you
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script..invoking command and exiting at fixed intervals

Hi, I need to write a shell script. Based on command line param to script say demode=yes Need to run an ant command for an hour(configurable) Then exit Again run the ant command all this needs to be in a loop. Thanks in advance Raj (1 Reply)
Discussion started by: rajuak12
1 Replies

2. Shell Programming and Scripting

script to run repeatedly after a fixed interval of time

Hi , I am working on the following script . I want this script to run and scan the log file repeatedly after 3 hours. This script will run & scan just for the current date logs and after every 3 hours. Kindly advice what to add in this script for this purpose. #!/bin/sh diff common.log... (3 Replies)
Discussion started by: himvat
3 Replies

3. Shell Programming and Scripting

Need awk script to compare 2 fields in fixed length file.

Need a script that manipulates a fixed length file that will compare 2 fields in that file and if they are equal write that line to a new file. i.e. If fields 87-93 = fields 119-125, then write the entire line to a new file. Do this for every line in the file. After we get only the fields... (1 Reply)
Discussion started by: Muga801
1 Replies

4. Shell Programming and Scripting

Help with executing parallel sessions for same shell script with different but fixed parameters

Hi Experts, There is a shell script that accepts positional parameter between 1-25 to execute case statement of script depending upon the parameter passed. Now I need to run all the 25 sessions parallely. In each option of case statement it is connecting with sqlplus and executing a select... (11 Replies)
Discussion started by: Opamps123
11 Replies

5. Shell Programming and Scripting

Concatenating fixed length lines in shell script

I have a peculiar file with record format like given below. Each line is wrapped to next lines after certain number of characters. I want to concatenate all wrapped lines into 1. Input:(wrapped after 10 columns) This is li ne1 This is li ne2 and this line is too lo ng Shortline ... (8 Replies)
Discussion started by: kmanyam
8 Replies

6. UNIX for Dummies Questions & Answers

Help with Fixed with data

Hi I have a data with varying length i need to convert it to data of fixed length 1000 by appending blank spaces. This has to be done only for specific records i tried with awk but it not happening. Pls suggest me some advices awk '/^500/ {$0=sprintf("%s%t" w-length "s", $0,x)}1'... (12 Replies)
Discussion started by: akshay01987
12 Replies

7. Shell Programming and Scripting

[Fixed Itself!] Sending mail form script using sSMTP does not work

I have installed sSMTP and set it up to use my gmail. Sending from cli does work fine: msg file:From: test@gmail.com To test2@gmail.com Subject: test post This is a test Executing from console:ssmtp -t < msg does work fine. But from script it does not work:#!/bin/sh ssmtp -t < msg... (0 Replies)
Discussion started by: Jotne
0 Replies

8. Shell Programming and Scripting

Fixed Length file from a SQL script

Hi, I have a DB2 UDB 9.7 SQL script, as follows: I need to pass the script into Unix and generate a fixed length file from this. Can someone kindly provide a script to achieve it? SELECT CAST(COALESCE(CL_ID,'000000000') AS CHAR(9)) AS CL_ID ,STATUS... (5 Replies)
Discussion started by: ebsus
5 Replies
rc(1M)																	    rc(1M)

NAME
rc - general purpose sequencer invoked upon entering new run level SYNOPSIS
DESCRIPTION
The shell script is the general sequencer invoked upon entering a new run level via the command (where N equals 0-6). The script is typi- cally invoked by the corresponding entry in the file as follows: is the startup and shutdown sequencer script. There is only one sequencer script and it handles all of the sequencer directories. This script sequences the scripts in the appropriate sequencer directories in alphabetical order as defined by the shell and invokes them as either startup or kill scripts. If a transition from a lower to a higher run level (i.e., init state) occurs, the start scripts for the new run level and all intermediate levels between the old and new level are executed. If a transition from a higher to a lower run level occurs, the kill scripts for the new run level and all intermediate levels between the old and new level are executed. If a start script link (e.g., in sequencer N has a stop action, the corresponding kill script should be placed in sequencer (e.g., Actions started in level N should be stopped in level This way, a system shutdown (e.g., transition from level 3 directly to level 0) will result in all subsystems being stopped. Start and Kill Scripts In many cases, a startup script will have both a start and a kill action. For example, the inetd script starts the Internet daemon in the start case, and kills that process in the stop case. Instead of two separate scripts, only one exists, which accepts both the and argu- ments and executes the correct code. In some cases, only a start action will be applicable. If this is the case, and if the action is specified, the script should produce a usage message and exit with an error. In general, scripts should look at their arguments and pro- duce error messages if bad arguments are present. When a script executes properly, it must exit with a return value of zero. If an error condition exists, the return value must be nonzero. Naming Conventions The startup and shutdown scripts (referred to as startup scripts hereafter) exist in the directory, named after the subsystem they control. For example, the script controls starting up the daemon. The contents of sequencer directories consist of symbolic links to startup scripts in These symbolic links must follow a strict naming convention, as noted in the various fields of this example: where the fields are defined as follows: The sequencer directory is numbered to reflect the run level for which its contents will be executed. In this case, start scripts in this directory will be executed upon entering run level 2 from run level 1, and kill scripts will be executed upon entering run level 2 from run level 3. The first character of a sequencer link name determines whether the script is executed as a start script (if the character is or as a kill script (if the character is A three digit number is used for sequencing scripts within the sequencer directory. Scripts are executed by type (start or kill) in alphabetical order as defined by the shell. Although it is not recommended, two scripts may share the same sequence number. The name of the startup script follows the sequence number. The startup script name must be the same name as the script to which this sequencer entry is linked. In this exam- ple, the link points to Note that short file name systems require file names of 14 or less characters. This means that the fourth field is limited to 10 or fewer characters. Scripts are executed in alphabetical order. The entire file name of the script is used for alphabetical ordering purposes. When ordering start and kill script links, note that subsystems started in any given order should be stopped in the reverse order to eliminate any dependencies between subsystems. This means that kill scripts will generally not have the same numbers as their start script counterparts. For example, if two subsystems must be started in a given order due to dependencies (e.g., followed by the kill counterparts to these scripts must be numbered so that the subsystems are stopped in the opposite order in which they were started (e.g., followed by Also keep in mind that kill scripts for a start script in directory will reside in For example, and might be start/kill counterparts. Arguments The startup/shutdown scripts should be able to recognize the following four arguments (where applicable): The argument is passed to scripts whose names start with Upon receiving the argument, the script should perform its start actions. The argument is passed to scripts whose names start with Upon receiving the argument, the script should perform its stop actions. The argument is passed to scripts whose names start with so that the script can report back a short message indicating what the start action will do. For instance, when the spooler script is invoked with a argument, it echoes This string is used by the startup routines. Scripts given just the argument will only print a message and not per- form any actions. The argument is passed to scripts whose names start with so that the script can report back a short message indicating what the stop action will do. For instance, when the spooler script is invoked with a argument, it echoes This string is used by the shutdown checklist. Scripts given just the argument will only print a message and not perform any actions. Script Output To ensure proper reporting of startup events, startup scripts are required to comply with the following guidelines for script output. o Status messages, such as must be directed to stdout. All error messages must be directed to stderr. o Script output, both stdout and stderr, is redirected to log file unless the startup checklist mode is set to the raw mode. In this case, all output goes to the console. All error messages should be echoed to stdout or stderr. o Startup scripts are not allowed to send messages directly to the console, or to start any daemons that immediately write to the console. This restriction exists because these scripts are now started by the checklist wrapper. All script output should go to either stdout or stderr, and thus be captured in a log file. Any console output will be garbled. o When a startup script returns an exit code of can display a specific message on the console prior to rebooting the system. This is achieved by creating a text file named containing the text to be displayed to the console. Note that deletes this file after displaying the message, so startup scripts need to write this file each time a specific message is required to be displayed on console prior to reboot. RETURN VALUE
The return values for startup scripts are as follows: Script exited without error. Script encountered errors. Script was skipped due to overriding control variables from files, or for other reasons, and did not actually do anything. Script will automatically reboot the system. Script exited without error and started a process in background mode. For return values greater than the action is same as return value script encountered errors. SEE ALSO
init(1M), shutdown(1M), inittab(4), rc.config(4). rc(1M)
All times are GMT -4. The time now is 02:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy