larryperl 0 Light Poster

Then how can i delete the logfile attached ,so that i will be able to edit the post.

Thanks

larryperl 0 Light Poster

Hi,

I want to edit post, i made some days back. i could not see any edit link there in the thread. Kindly help me out this.

Moderators,

Please let me know the answer of above question, or delete all my posts from the forum. Please do it as soon as poosible, i will be thankful.

Thanks

larryperl 0 Light Poster

Hi,

I have a my script here--

print "The Perl Script does the User health check and system health check...\n";
print "---------------------------------------------------------------------\n";
# use strict;
my($OS);
$OS = $^O;
# need to test @ARGV before GetOptions shifts it
if (@ARGV == 0) {
   print "\nNo options provided, using defaults (use -h to view options)\n";
}

#GetOptions( 'h|help' => \$_help
        #   ,'u|userdata' => \$_userdata
        #   ,'s|systemdata' => \$_systemdata
		 #  ,'a|authresponsecode' => \$_authresponsecode
		 #  ,'o|outpur_dir' => \$_output_dir);
	  
#if( $_help ) {
  # printUsage(); # automatically exits the program
#}
use Getopt::Std;


##############################################################################
# Print the usage info and automatically exit
##############################################################################
sub printUsage() {
   print "\n\nUsage:";
   print "\n  perl MSLogStat.pl [options] [logfile1] [logfile2] ... [logfile(n)]";
   print "\n\nOptions:";
   print "\n  -h            * display usage help";
   print "\n  -o            * redirect the output to a directory";
   print "\n  -u            * display user related data";
   print "\n  -a            * display auth response codes";
   print "\n  -s            * output only system related data";
   print "\n";
   exit;
}
##############################################################################
# Print the authresponsecode
##############################################################################
sub authResponseCode () {
	print "AAFW_AUTH_SUCCESS				= 0";
	print "AAFW_AUTH_MORESTEPS				= 1";
	print "AAFW_AUTH_ID_NOT_FOUND			= 2";
	print "AAFW_AUTH_INVALID_CREDENTIAL	    = 3";
	print "AAFW_AUTH_ACCOUNT_EXPIRED		= 4";
	print "AAFW_AUTH_ACCOUNT_INACTIVE		= 5";
	print "AAFW_AUTH_ATTEMPTS_EXHAUSTED	    = 6";
	print "AAFW_AUTH_TOKEN_EXPIRED			= 7";
	print "AAFW_AUTH_CHALLENGE_EXPIRED		= 8";
	print "AAFW_AUTH_INVALID_REQUEST		= 9";
	print "AAFW_AUTH_CRED_REISSUED			= 10";
	print "AAFW_AUTH_INTERNAL_ERROR		    = 11";
	print "AAFW_AUTH_UNSUPPORTED_MECH		= 12";
    print "AAFW_AUTH_LAST					= 13";
}
# redirect output to a directory:
if( $_output_dir ) {	
   # does this directory already exist?
   if (! -e $_output_dir) …
larryperl 0 Light Poster

Hi,

I am explaing these question as this will be easy to understand the problem-
1. How are you relating session ids to users? Is the user id listed in the logfile or do you have a separate list?

2. How are the session ids related to authentication methods? Again, is this information available in the logfile or do you have a separate list?

:

1.. Yes userID is is listed in the logfile by name userName. When we search for the userName, it gives us details about the userName and which sessionID's it belongs.SessionID comes after tid value and leaving one more field after that,consisting of 8digits. each seesion id gives us the details about which mechanism it belongs to.
2. Each sessionID belongs to a mechanism,if we specifically search for the SessionID's it will show the details like this.
	

Tue May 19 22:29:12.634 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 0: 10081229: Message: ArAuthBinaryAuthRequestMgr::setSecurityInfo: security_info_offset [0] is invalid. Assuming security info not available. 
Tue May 19 22:29:12.634 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 60: 10081229: Entering [MechQnA::handleAuthRequest] 
Tue May 19 22:29:12.634 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 60: 10081229: Exiting [MechQnA::handleAuthRequest] 
Tue May 19 22:29:12.634 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 17: 10081229: Using session identifier [1:10081229] 
Tue May 19 22:29:12.634 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 160: 10081229: Entering QnAModule::openSession 
Tue May 19 22:29:12.634 2009 Morocco Standard Time INFO: …
larryperl 0 Light Poster

Hi,

I am writing a perl script and need some in extracting some data. Basically it is a Log Analyzer and there are multiple log files from where the data comes.

i am done with the grep part of the userID with this code-

#!/usr/bin/perl -w
open(VALUE, "< arcotwebfort_20May09_00_03_55.log");
@stock = <VALUE>; 
@matches = (grep(/$username/, @stock));
print @matches;

it gave me this output--
Tue May 19 23:46:29.946 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 17: 10088781: ArAuthFrameworkImpl::doPreAuth::1:10088781:: Authentication mechanism returned [0] for AuthIdentity [01402629;ARCARD]
Tue May 19 23:46:29.946 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 17: 10088781: ArAuthFrameworkImpl::doAuth::1:10088781:: Authentication mechanism returned [1] for AuthIdentity [01402629;ARCARD]
Tue May 19 23:46:29.946 2009 Morocco Standard Time INFO:    pid 2172 tid 688: 17: 10088781: ArAuthFrameworkImpl::doPostAuth::1:10088781:: Authentication mechanism returned [1] for AuthIdentity [01402629]
Tue May 19 23:47:14.149 2009 Morocco Standard Time INFO:    pid 2172 tid 3352: 17: 10088815: ArAuthFrameworkImpl::doPreAuth::1:10088815:: Authentication mechanism returned [0] for AuthIdentity [01402629;ARCARD]
Tue May 19 23:47:14.165 2009 Morocco Standard Time INFO:    pid 2172 tid 3352: 17: 10088815: ArAuthFrameworkImpl::doAuth::1:10088815:: Authentication mechanism returned [1] for AuthIdentity [01402629;ARCARD]
Tue May 19 23:47:14.165 2009 Morocco Standard Time INFO:    pid 2172 tid 3352: 17: 10088815: ArAuthFrameworkImpl::doPostAuth::1:10088815:: Authentication mechanism returned [1] for AuthIdentity [01402629]

i got the sessionID's from this,they are-10088781,10088815. like this there are plenty of sessionID related to a single user.

i collected this information in an array @matches. now i want to take sessionID's from this array and search for the sessionID in the logfile …

larryperl 0 Light Poster

i could not understand what u said, as i am totally new to these terminologies.
can you please guide me to do so.
I will be thankful for your help..

larryperl 0 Light Poster

Hi Experts,

i have this code --

<%-- 
    Document   : index
    Created on : Nov 10, 2008, 3:25:29 PM
    Author     : namish
--%>

<%@page import="java.sql.*"%>


<html>
<head>
<title>Obtaining a Connection</title>
</head>
<body>
<h1>This Page Obtains a Connection to a Database and executes a query</h1>
<%
    Connection conn = null;
    ResultSet result = null;
    Statement stmt = null;


    try {
      Class c = Class.forName("oracle.jdbc.driver.OracleDriver");
    }
    catch (Exception e) {
      System.out.println("Error occurred " + e);
     }
     try {
       conn = DriverManager.getConnection("jdbc:oracle:thin:nameesh/dost1234@(description=(address_list=(address=(protocol=tcp) (host=arcot-w2kts01)(port=1521))) (source_route=yes)(connect_data=(sid=ts)))"); 


     }
     catch (SQLException e) {
        System.out.println("Error occurred " + e);
     }
     try {
        stmt = conn.createStatement();
        result = stmt.executeQuery("SELECT * FROM ARUSER; ");
        int count=0;
        while (result.next())
        {
        System.out.println("UserName :: "+result.getString(1)+" , Groupname :: "+result.getString(2)+" , Firstname :: "+result.getString(3)+" ,Latname :: "+result.getString(4)+" ,Pam :: "+result.getString(5)+" , Email :: "+result.getString(6));
        count++;
        }
        System.out.println(count+" records selected...");

     }
     catch (SQLException e) {
         System.out.println("Error occurred " + e);
      }

%>

in this i am only getting the header part but the jsp part is not run.
what can be the problem here. when i ran this jsp i got "This Page Obtains a Connection to a Database and executes a query", but the desired output is the result of the query.I am doing something wrong here.

Thanks
NT

larryperl 0 Light Poster

Hi ,

I am usinga code to connect to database. here is the code--

<html>
<head>
<title>Obtaining a Connection</title>
</head>
<body>
<h1>This Page Obtains a Connection to a Database and executes a query</h1>
<%
    Connection conn = null;
    ResultSet result = null;
    Statement stmt = null;


    try {
      Class c = Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }
    catch (Exception e) {
      System.out.println("Error occurred " + e);
     }
     try {
       conn = DriverManager.getConnection("jdbc:odbc:namish") ;
     }
     catch (SQLException e) {
        System.out.println("Error occurred " + e);
     }
     try {
        stmt = conn.createStatement();
        result = stmt.executeQuery("SELECT * FROM ARUSER; ");
     }
     catch (SQLException e) {
         System.out.println("Error occurred " + e);
      }

%>

when i am trying to run this i am getting null pointer exception error.
can you please help me in rectifying this problem. I have created a DSN name namish and using that.it is the right way to do it or any other way i should proceed..

Thanks
NT

larryperl 0 Light Poster

can you provide some idea in reference to my code about how to connect with db in this case.

Thanks
NT

larryperl 0 Light Poster

Hi Everyone,

I need some suggestions from you guys. I am totally unaware of JSP or java and trying to learn a bit , as i need to develop a sample application using web services.I am in need of some help from you guys. If there are some errors in the code or i can modify for the better then please tell me.Please explain the things as i am a layman..

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <h2>Hello World!</h2>
                
    <%-- start web service invocation --%><hr/>
    <%
    
        String userName=" ";
        String groupName=" ";
        String firstName=" ";
        String lastName=" ";
        String pam=" ";
        String emailAddress=" ";
    try {                                     
	com.arcot.schemas.regfort.v2.AuthProvisionAPIService service = new com.arcot.schemas.regfort.v2.AuthProvisionAPIService();
	com.arcot.schemas.regfort.v2.RegFortAPIPortType port = service.getRegFortAPISOAP11Port();
        port.createUser(userName, groupName, firstName, lastName, pam, emailAddress);
            } catch (Exception ex) {
	// TODO handle custom exceptions here
    }
    %>
    <form action="response.jsp" method="POST">

<table>
    <tr><td>User Name</td><td><input type="text" name="userName" value="" /></td></tr><br></br>
    <tr><td>Group Name</td><td><input type="text" name="groupName" value="" /></td></tr><br></br>
    <tr><td>First Name</td><td><input type="text" name="firstName" value="" /></td></tr><br></br>
    <tr><td>Last Name</td><td><input type="text" name="lastName" value="" /></td></tr><br></br>
    <tr><td>PAM</td><td><input type="text" name="pam" value="" /></td></tr><br></br>
    <tr><td>Email Address</td><td><input type="text" name="emailAddress" value="" /></td></tr>
    <tr><td>Submit</td><td><input type="submit" name="submit" value="submit"/></td></tr>
</table> 
</form>
    <%-- end web service invocation --%><hr/>    
    </body>
</html>

I am using netbeans here.

now what i need to do is----

when i click on the submit button the entries should be updated in the database, how i can achieve that. syntax for database connection. i am using oracle as DB.

larryperl 0 Light Poster

I am not familiar with awk and very little knowledge of sed i have.So i need help of you guys.

Thanks..

larryperl 0 Light Poster

Hi,

I have two files--

file1-


Quote:
dn: cn=Anandmohan Singh,ou=addressbook,dc=thbs,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Anandmohan Singh
givenName: Anandmohan
mail: anand_ms@thbs.com
mobile: 9986010455
ou: null
physicalDeliveryOfficeName: ST-6th Floor
sn: Singh
telephoneNumber: 41827200 Extn: 7400
title: Associate Software Engineer - Trainee
uid: 1432

dn: cn=Riteshkumar Mohanty,ou=addressbook,dc=thbs,dc=com
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Riteshkumar Mohanty
givenName: Riteshkumar
mail: ritesh_m@thbs.com
mobile: 9916953109
ou: null
physicalDeliveryOfficeName: ST-6th Floor
sn: Mohanty
telephoneNumber: 41827200 Extn: 7400
title: Associate Software Engineer - Trainee
uid: 1418

file2:-


Quote:
uid:Password
0050:thbs
1418:thbs
1432:thbs

i have to compare two files and where the uid is same i have to take the password and insert it above the telephone number.

the output should be like this--

uid : 1418 common so insert the password thbs above the line telephonenumber.

larryperl 0 Light Poster

Hi,

With little modifications,i was able to run the script as i wanted.Tha options which u mentioned is working perfectlly fine.Your help is a great support.Hope to discuss some issues again with you in near future.If u want the whole script i can attach it for you without any problem.

Thanks.

larryperl 0 Light Poster

I am able to resolve the problem,thanks guys for yourvalueable inputs,SPecial thanks to Mike who gave his time to me.

Thanks.

larryperl 0 Light Poster

I got the problem resolved for the issue.Actually in the script i was setting the flag to 1 at one more place so i removed that part.

Now the problem is coming for the delete part----

for deletion we ned not to specify any location,it will delete all the files at the default location.

when i ran the scaript as-

webmut2@france>mt_clean -a mtDelete
Either option l or L should be given to mt_clean
Usage: mt_clean [-a mtDelete/mtBackup] [-l/-L Backuplocation] [-t now/cron/hh:mm]
mt_clean is terminated

instaed of this it should delete the files at the default location,Help me in this please.

Thanks...

larryperl 0 Light Poster

Still i am getting the same error--

>mt_clean -a mtBackup -l /intasmut2/kp -t now
>Backup directory already exists
>mt_clean starts Now
>Either option l or L should be given to mt_clean
>Usage: mt_clean [-a mtDelete/mtBackup] [-l/-L Backuplocation] [-t now/cron/hh:mm]
>mt_clean is terminated

but it should not do like this.
it should take the backup at the desired location.

larryperl 0 Light Poster

Hey there,

Is it still not working?

Thanks :)

, Mike

It is working for the option which i mentioned in the script-
mt_clean -a mtBackup

but for

mt_clean -a mtbackup -lor -L /intasmut2/abc -t now/time

it is not working

larryperl 0 Light Poster

Hi Mike,

it is running fine for the option--

mt_clean -a mtBackup

but when i am running it for common usage of the script like--

mt_clean -a mtBackup -l /intasmut2/kp -t now

the program is terminated also.

I tell u the changes i did in the script--

lFlag=1
LFlag=1
while  getopts a:l:L:t: optvar

-----------------------------------------------

l) BackupLocation="$OPTARG"
		lFlag=0

-------------------------------------------------

L) BackupLocation="$OPTARG"
		LFlag=0

-----------------------------------------------

*) echo $Usage
	   return $ERR 
	  	;;
	esac
done
                        if [[ $lFlag -eq 1 || $LFlag -eq 1 ]]; then
			        echo "Either option l or L should be given to $Programname"
			        echo "$Usage"
			        echo "$Programname is terminated"
			        return $ERR;
		        fi

This is the primary use of the script

mt_clean -a mtBackup -l /intasmut2/abc -t now/time
or
mt_clean -a mtBackup -L /intasmut2/abc -t now/time

but it should not do it for --

mt_clean -a mtBackup

larryperl 0 Light Poster

Hey There,

You're checking whether or not the -l OPT is being passed in the option argument, so if the -l flag isn't passed to the program, it won't know to even check if there's an error.

I would recommend setting the lFlag variable to whatever the "off" value is, before parsing your opt args, and only set it to "on" if the option is called. Then, after processing your opt args, do the check for the value of $lFlag.

That should take care of it for you.

Hope that helps :)

, Mike

Hi Mike,
can you explain me just giving me the sample change i need to put in my script.I aperciate your help.

larryperl 0 Light Poster

What is the actual out put it is giving?

it is giving me the desired outputs but when i put only

mt_clean -a mtbackup

it is copying the files at the default location but i want it like this

whne i put
mt_clean -a mtbackup

then it should not do anything instead of doing copy it should come out displaying the Usage.
the actual output is--
mt_clean -a mtBackup
Starting moving/removing files from /intasmut2/envsw/logs
Skips ./sage_db_clean_up.result file. It is today's file
Skips ./mt.log.8882.-5 file. It is today's file
Skips ./sage.log.5 file. It is today's file
Skips ./mt.log.8882.-6 file. It is today's file
Skips ./Trace28482main1 file. It is today's file
Skips ./dispatcher.log.8881.-6 file. It is today's file
Skips ./Trace28591main1 file. It is today's file
mt_clean is completed suffessfully


Need help in this.
Thanks

larryperl 0 Light Poster
Programname=$(basename $0)  # While scheduling to cron, program name is needed.

Usage="Usage: $Programname [-a mtDelete/mtBackup] [-l/-L Backuplocation] [-t now/cron/hh:mm]"

IsCronJob=1     # default, script will run at now.
isBackUp=0	# default, it will take back up.
lFlag=0		# it is optional. default value is zero
LFlag=0		# it is optional. dfault value is zero
ERR=1
 
LOGDIR="$INTAS_INSTALL_DIR/envsw/logs"
BackupLocation="$INTAS_INSTALL_DIR/mt_backup"

mtlogFile="/tmp/mtclean.log.$$"

if [[ $# -lt 1 ]];
then
	echo "$Usage"
	return $ERR
fi

if [[ ! -d $BackupLocation ]];
then
	mkdir -p $BackupLocation 2>/dev/null
fi

while  getopts a:l:L:t: optvar
do
	case $optvar in
	a) action="$OPTARG"
		if [[ $action = "mtBackup" ]];
		then
			isBackUp=1
		fi
		;;
	l) BackupLocation="$OPTARG"
		if [[ $lFlag -eq 1 ]]; then
			echo "Either option l or L should be given to $Programname"
			echo "$Usage"
			echo "$Programname is terminated"
			return $ERR;
		fi
		if [[ $isBackUp -eq 1 ]];
		then	
			givenPath="$BackupLocation"
			if [[ ! -d $BackupLocation ]];
			then
				echo "Non-existant directory specified"
				
				mkdir -p $BackupLocation >/dev/null 2>&1
	                        if [[ $? = 0 ]];
        	                then
					echo "$Prograname creates the dirctory $BackupLocation"
				else
					echo "$Programname could not able to create the directory $BackupLocation"
					return $ERR
				fi
			else
				echo "Backup directory already exists"
			fi
			lFlag=1
			Llcron=l
		else
			echo "$Programname is executed with -l option without action mtBackup"
			echo "$Usage"
			echo "$Programname is terminated"
			return $ERR
		fi
		;;
	L) BackupLocation="$OPTARG"
		if [[ $LFlag -eq 1 ]]; then
			echo "Either option l or L should be given to $Programname"
			echo "$Usage"
			echo "$Programname is terminated"
			return $ERR;
		fi
		if [[ $isBackUp -eq 1 ]];
		then
		        givenPath="$BackupLocation"
			BackupLocation=$BackupLocation/backup$(date …
larryperl 0 Light Poster
extrafiles1=$(ls mt.*.*.*.*) 
extrafiles2=$(ls *core*)

my question is--
suppose if there is no files matching with the criteria mentioned above it will display message on the window--
mt.*.*.*.* not found
*core* not found

i do not want to display this message on the window even if it do not find any files matching with the criteria,how can i do that.

larryperl 0 Light Poster

Here is part of my code-

extrafiles1=$(ls mt.*.*.*.*) 
            if [[ $(ls -l $file 2>/dev/null) = *$today* ]]; 
		then
                           if [[ $file -eq $extrafiles1 ]];then
                                    rm $file
                           fi
            fi

when i am running the script it's showing an error--

mtclean[239]: ./mt.log.8882.-5.1202989443474: bad number.
when i just ran this command on the unix prompt itgave me this--
webmut2@france>extrafiles1=$(ls mt.*.*.*.*)
webmut2@france>$extrafiles1
ksh: mt.log.8882.-5.1202983177934: cannot execute
these files dont have execute permission,but they do have -r-w permissions.i have to delete the files with that extensions,please help me out in tht.

why it is so,is the variable assignment is not right.Give me ur suggestions.

--------------------------------------------------------------------------------

larryperl 0 Light Poster

try to use different variables instead of appending /backup to a single location variable

if i use a different variable to store the backuplocation,then when i am running cron the backup is taken in to current directory ie
if backuplocation is /home/namish/backup

when i run the script through cronjob ten it is taking backup at /home/namish not in backup directory.may be some problem in assignment of the variables,that is why i am looking for a help.

Thanks.

larryperl 0 Light Poster

just use $Backuplocation (without the /backup after it) then

btw, does it work right when run manually, outside of cron?

yes it does work properly when i run it without cron.

it should work like this ---

if i am running it without cron--it checks for the directory existance,if it is there then it creates the dir backup and take the backup of the files,because i am assigning it like this
BackupLocation=$BackupLocation/backup

it runs first time as soon as i run the script,when i run it through cron at a specific time it again creates the dir backup inside BackupLocation(which is now $BackupLocation/backup)

i just want to createit once whether i run it through cron or now.i need to change a bit in the script but notgetting how to do.So your help is required in this.

Thanks

larryperl 0 Light Poster

are you backing up a directory called "backup" as well?

No Dima,i am not,every time i run the script it should create a directory backup inside any specific dir and then take backup,when i run cron job the problem is coming,because at the first time it is creating the directories and again at the cron time it is doing the same.

in simple words--
it should take backup always in a directory--

$dir/backup

whether i run it through cron timings or just now.

Thanks.

larryperl 0 Light Poster

remove -p from mkdir

Thanks Dima for paying attention.
still the problem exists.
i removed the -p option,still when i run the script through cron it's creating a directory

/home/namish/backup/backup

this last backup is redundent i just want to remove that part.

Thanks

larryperl 0 Light Poster

Hiiii,

here is my script--

:
BackupLocation="$OPTARG"
                if [[ $LFlag -eq 1 ]]; then
                        echo "Either option l or L should be given to $Programname"
                        echo "$Usage"
                        echo "$Programname is terminated"
                        return $ERR;
                fi
                if [[ $isBackUp -eq 1 ]];
                then
                        if [[ ! -d $BackupLocation ]];
                           then
                                echo "Non-existant directory specified"
                        fi
                               #givenPath="$BackupLocation"
                                BackupLocation=$BackupLocation/backup
                                mkdir -p $BackupLocation >/dev/null 2>&1
                                if [[ $? = 0 ]];
                                then
                                        echo "$Programname creates the dirctory $BackupLocation"
                                else
                                        echo "$Programname could not able to create the directory $BackupLocation"
                                        return $ERR
                                fi


                        lFlag=1
                        Llcron=l
                else
                        echo "$Programname is executed with -l option without action mtBackup"
                        echo "$Usage"
                        echo "$Programname is terminated"
                        return $ERR
                fi
                ;;

when i run this script through cronjob,then i am getting a directory creation problem.

supoose the directory name which i am giving is--

/home/namish
then my creates a directory called

/home/namish/backup

when i run it through cron then it again creates the directory backup inside backup directory.I can see my script is like that only but i want to modify this,can you please give me some valueable inputs so that this problem can be resolved.

The outcome should be when i run the script through cron it should not create the dir inside the backup di,instaed it should take backup onlyin the dir /home/namish/backup.If you need any moreclarification then please let me know.

Thanks..

larryperl 0 Light Poster

Hiii,

i have a doubt here--

DirCleanupList="logs tmp corefiles"
echo "$DirCleanupList" | perl -ne 'print join("\n", split(" ")) . "\n"; '
for dir in $DirCleanupList
do
BackupLocation="$BackupLocation/$dir"
mkdir -p $BackupLocation >/dev/null 2>&1
if [[ ! -d $BackupLocation ]]; then
echo "Unable to make backup directory: $BackupLocation"
continue
fi
done

I have to take backup of all the files inside directory dir(logs,tmp,corefiles) at the location $BackupLocation.i should take the backup of logs,tmp,corefiles inside the $BackupLocation directory and then remove the files and touch the files inside the directory dir(logs,tmp,corefiles).
else we can move the files from dir(logs,corefiles,tmp) to $BackupLocation then touch the file inside dir(logs,tmp,corefiles).

i appericicate your quick help.

larryperl 0 Light Poster

where is the default location, and how do you acquire an alternative?

Dima,

if you can look in the script which i wrote,at the beginning of this thread,i am implementing the functionality of copying inside the backuplocation itself actually we dont need this.
i need to write it like
if mention as now it should take the backup now otherwise when i schedule the cron part.

i tell you my actual requirement--

1)Utility will be run under Specific owner.
2) This utility will clean files in $INTAS_INSTALL_DIR/envsw/logs. And following logs will be backed up or deleted.

All Logs and Core files
3) mt_clean -a<action> [-t <time>] -L <backup location>

-a<action> - has two values "delete" or "backup”. If not specified by default "delete" action will occur. If "backup" option is given, files will be backed up on the location specified by the -L, -L is mandatory if back up option is specified.

-t<time> - The time is given with the -t option and its default is 1am

A time of 'now' means to execute the cleanup operation now
A time of 'never' means that the cleanup operation should not be scheduled and any existing cleanup should be cancelled.

-L <backup location> - this field is mandatory if backup action is selected.

Note: As middle tier process are running and not stopped while this utility is running, the utility should create an empty file with same name which has deleted or …

larryperl 0 Light Poster

Hi Dima,

any solution for the default backup location problem which i mentioned just above your last thread.

larryperl 0 Light Poster

in the backup script file collect minute, hour, day, month, weekday
add the crontab -e command there (this will create the crontab file, if it doesn't exist.
after that add:
/some/dir/CronInsert.sh $minute $hour $day $month $weekday
--------------------------------------------

CronInsert should be something like

echo "$1 $2 $3 $4 $5 /some/dir/BackupScript.sh >/tmp/backupcron.log" >>/etc/crontab

Can you give me some example in regard to this.This will be very helpfull.

if [[ $WhenToRun != 24:00 ]]; then
Llcron=l
minute=$(/bin/echo $WhenToRun | cut -d: -f2)
hour=$(/bin/echo $WhenToRun | cut -d: -f1)
if [[ -z "$DEBUGGING" ]]; then
echo "$minute $hour" '* * *' ". ~/.kshrc; $(whence $Progname) cron -e -$Llcron $BackupLocation $arg3" >>$cronfile
else
echo "$minute $hour" '* * *' ". ~/.kshrc; $(whence $Progname) cron -d -e -$Llcron $BackupLocation $arg3" >>$cronfile
fi

larryperl 0 Light Poster

I ned one more help,
if i run the script through cron and do not specify any backup location the copy should happen at the default backup location that is not happening only it is creating the default backup location.can you try to help me out in this also.
Thanks

larryperl 0 Light Poster

in the backup script file collect minute, hour, day, month, weekday
add the crontab -e command there (this will create the crontab file, if it doesn't exist.
after that add:
/some/dir/CronInsert.sh $minute $hour $day $month $weekday
--------------------------------------------

CronInsert should be something like

echo "$1 $2 $3 $4 $5 /some/dir/BackupScript.sh >/tmp/backupcron.log" >>/etc/crontab

Can you explain me in reference to my script that will much more helpfull.Where should i use these lines.
add the crontab -e command there -> i know in the file but where in the file.

/some/dir/CronInsert.sh $minute $hour $day $month $weekday ->what this line isgoing to.

can you elaborate all this is respect to my file,that way i can get much more and do the things.

larryperl 0 Light Poster

CAn you do me a favour if you can help me out in creating that crontab part.i am new to unix and to shell scripting.i created the script as i have a similar script but that is doing diffrent things.i will apperciate your help in this.

larryperl 0 Light Poster

I said I WOULD create a script, not that i WILL write it for you

No Problem Dima,i appericiate your help.You mean to say you will help me in rectifying the script right.That is also fine to me.

larryperl 0 Light Poster

Hi Dima,

did you write the script that will help me in this regard.

larryperl 0 Light Poster

I appericiate your help.I wil wait for your response.

larryperl 0 Light Poster

Yes that is an option, but It is required in the script which i ned to write.
I have to do the cronjob part inside the script itself.

larryperl 0 Light Poster

Yes it is working properly.the problem is it is not taking the time which i specify.the script can be run as

mt_clean -a backup/delete -l|L <location> -t 02:00(eg)

but as soon as i run it it is taking the backup but not at the specified time.Cronjob part is not working properly.i guess i need to modify the script but how to do that i am not getting,so i need your help in this regard.

Thanks

larryperl 0 Light Poster

Hi unix guru's,

i did not get even a single response till now regarding my quesry ie-

can nayone please suggestt me how i can implement the cronjob part inside a script like it is mentioned in the above script.i am not a unix guy and got into this problem.i will appericiate if anyone giveme me some clues also.

please explain me how the cronjob part can be implemented inside a script.i just want to run the file and the script will do the rest.
one more problem is there the backup is not being taken at the default location if no location is specified.

if you need any clarification then let me know but suggest me something so that i can proceed further.
Thanks

larryperl 0 Light Poster

Here is mywhole script.

WhenToRun="01:00"

FilesToDelete="*log* *.log*"
FileLocation="$INTAS_INSTALL_DIR/envs/logs"
if [[ ! -d $FileLocation ]];then
echo "The FileLocation specified in Non-Existant"
fi
Progname=$(basename $0)

Usage="Usage:$Progname"'[-a <delete or backup>] [-l|-L <backup location>] [ -t <time>]' 
     IsCronJob=0
if [[ "$1" = "cron" ]]; then
	. ~/.kshrc
	IsCronJob=1
	if [[ -z "$INTAS_INSTALL_DIR" ]]; then
		echo "You must be logged in as the application owner to delete the middle tier logs"
		return 1
        fi	
fi

BackupLocation="$INTAS_INSTALL_DIR/mt_backup"
if [[ ! -d $BackupLocation ]];then
mkdir -p $BackupLocation
fi
TEMPDIR=/tmp
if [[ -d $INTAS_INSTALL_DIR/envsw/tmp ]]; then
	TEMPDIR=$INTAS_INSTALL_DIR/envsw/tmp
fi

while getopts a:l:L:t:d optvar
do
	case $optvar in

	a)option="$OPTARG"
            if [[ $option = "delete" ]]; then
              echo "Deleting the middletier logs" 
	      cd $FileLocation
	      list=$(ls *log*)
              for files in $list
               do
		rm -f $files
                touch $files 
                echo " Middletier is cleaned up" 
                done
            fi
             if [[ $option = "backup" ]]; then
              echo "Backuplocation is must to specify"
             fi
             ;; 
	l) BackupLocation="$OPTARG"
	        if [[ ! -d $BackupLocation ]];then
		echo "Specify a existing directory"
		fi
		if [[ $BackupLocation != *backup ]]; then
			echo "Appending backup subdirectories"
			BackupLocation=$BackupLocation/backup
			mkdir -p $BackupLocation >/dev/null 2>&1
                        if [[ $? != 0 ]];then
                        echo "First Create The Directory And Then Take backup"
                        fi
                        cd $FileLocation
			list=$(ls *log*)
                        cp -R $FilesToDelete $BackupLocation
			
                        for files in $list
                        do
                          rm -f $files
			  touch $files 
                        done
                else
                        mkdir -p $BackupLocation >/dev/null 2>&1 
			list=$(ls *log*)
                        cp -R $list $BackupLocation
                        for files in $list
                        do
			  rm -f $files
                          touch $files 
                          done 
  		if [[ ! -d $BackupLocation ]]; then
    		echo "Unable to make backup …
larryperl 0 Light Poster

Here is the script which i am trying to write but its not creating the backuplocation.

#!/bin/ksh
# Copyright (c) 2000 Telcordia Technologies, Inc.,
# All Rights Reserved.
# 
# Telcordia Confidential - Restricted Access
# 
# This document contains proprietary information that shall be
# distributed or routed only within Telcordia Technologies, Inc.,
# and its authorized clients, except with written permission of
# Telcordia
# 
# @(#)mt_clean	107.2 01/18/08
# created on 01/18/08 at 08:58:17 Namish Tiwari

#Get the INTAS release number
RELEASE=${PATH##*/OCU_}
RELEASE=${RELEASE%%/bin:*}

DEBUGGING=''
WhenToRun="01:00"

FilesToBackup='*.track* *.xml *.vm* *.gz Trace* TRACE* *.core *.out fcif_data_* esi_error_* *.rollback *.sed R.* APStatus_*log* *.output* send_mail* downenv* check_env* intaspurge_db_* sqlnet.log *.rpt *.html *.csv *.log*'
FilesToDelete='*.log* *_log*'
FileLocation='$INTAS_INSTALL_DIR/envsw/logs'

PID_Templates='Trace\([0-9][0-9][0-9][0-9][0-9]\)_.* TRACE_\([0-9][0-9][0-9][0-9][0-9]\)_.* .*_\([0-9][0-9]*\).out'
Progname=$(basename $0)

Usage="Usage:$Progname"'[-a <delete or backup] [-t <time>] [-l|-L <backup location>]' 
     IsCronJob=0
if [[ "$1" = "cron" ]]; then
	. ~/.kshrc
	IsCronJob=1
	if [[ -z "$INTAS_INSTALL_DIR" ]]; then
		echo "You must be logged in as the application owner to delete the middle tier logs"
		return 1
        fi	
fi

BackupLocation="$INTAS_INSTALL_DIR/mt_backup"
TEMPDIR=/tmp
if [[ -d $INTAS_INSTALL_DIR/envsw/tmp ]]; then
	TEMPDIR=$INTAS_INSTALL_DIR/envsw/tmp
fi

mt_clean_errfile="$INTAS_INSTALL_DIR/envsw/logs/mt_clean.$(date +%a)"

cfile=$(/bin/ls -1t $(find $INTAS_INSTALL_DIR -follow -name 'CommonScriptSetup.ksh') | head -1)

if [[ -x $cfile ]]; then
	export PATH=$PATH:$(dirname $cfile)
	. $cfile
else
	echo "Unable to find common include file needed for execution"
        if [[ $IsCronJob -eq 1 ]]; then
	  SendIntasNotifyMail "Middletierclean error message" $mt_clean_errfile
	fi
	return 1
fi
   
while getopts a:t:l:L:d optvar
do
	case $optvar in

	a)option="$OPTARG"
            echo "Delete or Backup option"
            if [[ $option = "delete" ]]; then
              for files …
larryperl 0 Light Poster

I have to write a shell script like this--

1) Utility will be run under the directory owner.
2) This utility will clean files in ABC/logs. And following logs will be backed up or deleted.

Dispatcher Logs
Middle tier Logs
Sage log
Sage monitor log
Sage db clean up result log
Core files

3) mt_clean -a<action> [-t <time>]* -L <backup location>

-a<action> - has two values "delete" or "backup”. If not specified by default "delete" action will*occur. If*"backup" option is given, files will be backed up on the location specified by the -L, -L is mandatory if back up option is specified.

-t<time>* - The time is given with the -t option and its default is 1am
A time of 'now' means to execute the cleanup operation now
A time of 'never' means that the cleanup operation should not be scheduled and any existing cleanup should be cancelled.

-L <backup location> -*this field is mandatory if backup action is selected.

Note: As middle tier process are running and not stopped while this utility is running, the utility should create an empty*file with same name which has deleted or backed up. Otherwise middle tier logs will not be generated until the middle tier process is restarted. Any core files will be backed up or deleted according to the action chosen.*

Note-> mt_clean is the utility name.it can be run like this.

mt_clean …

larryperl 0 Light Poster

If any one has doubts please let me know,i will try to make u understand.I am also trying to debug the script.Experts help me out in this.
I Appericiate your help in advance.i need this script to be completed at an urgent basis.

larryperl 0 Light Poster

Hiii,
I have a requiremnt like this---

1) Utility will be run under MT owner.
2) This utility will clean files in ABC/envsw/logs. And following logs will be backed up or deleted.

Dispatcher Logs
Middle tier Logs
Sage log
Sage monitor log
Sage db clean up result log
Core files

3) mt_clean -a<action> [-t <time>]* -L <backup location>

-a<action> - has two values "delete" or "backup”. If not specified by default "delete" action will*occur. If*"backup" option is given, files will be backed up on the location specified by the -L, -L is mandatory if back up option is specified.

-t<time>* - The time is given with the -t option and its default is 1am
A time of 'now' means to execute the cleanup operation now
A time of 'never' means that the cleanup operation should not be scheduled and any existing cleanup should be cancelled.

-L <backup location> -*this field is mandatory if backup action is selected.

Note: As middle tier process are running and not stopped while this utility is running, the utility should create an empty*file with same name which has deleted or backed up. Otherwise middle tier logs will not be generated until the middle tier process is restarted. Any core files will be backed up or deleted according to the action chosen.*

It could be run as---

intasclean -a delete/backup now somelocation

I wrote the script like …

larryperl 0 Light Poster
Private Sub CommandButton7_Click()

'UAD_FLG

    Dim sValue1 As String
    Dim sValue2 As String
    Dim sValue3 As String
    Dim sValue4 As String
    Dim sValuex As String
    Dim sscript As String
    Dim sscript2 As String
    Dim sscript3 As String
    Dim x As String
    Dim finalstring As String
    
    Dim temp1 As Integer
    
    
    
   
    Dim lRow As Long
    Dim lRowx As Long
    Dim lColValue1 As Long
    Dim lColValue2 As Long
    Dim lColValue3 As Long
    Dim lColValue4 As Long
    Dim lColValue5 As Long
    Dim stemp1 As String
    Dim sum As Integer
    
    Dim a As String
    
  
    
    
    '====================================
    'FLAG 1 CALL
    '====================================
    lRow = 3
    lColValue1 = 5
    lColValue2 = 11
    lColValue3 = 12
    lColValue4 = 13
    
     Call WriteToTextFile10("")
    Call WriteToTextFile10("---------UDA_FLG started")

       
    While Not Cells(lRow, lColValue1) = ""
        sValue1 = Cells(lRow, lColValue1)
        sValue2 = Cells(lRow, lColValue2)
        sValue3 = Cells(lRow, lColValue3)
        sValue4 = Cells(lRow, lColValue4)
        
        sscript = "INSERT INTO SYS_PARAMS(SECTION_NM,VARIABLE_NM, VARIABLE_VALUE, CREATE_ID, CREATE_DT, UPDATE_ID, UPDATE_DT) Values('UAD_FLG','"
         
        sscript2 = ",'P22919',SYSDATE,'', NULL);"
       temp1 = 0
      sum = 0
       
       For lRowx = 3 To 78
            For lColValue5 = 11 To 13
            sValuex = Cells(lRowx, lColValue5)
            If lColValue5 <> 13 Then
                If sValuex <> "" Then
                sscript3 = sscript3 & sValuex & ","
                 sValuex = Cells(lRowx, lColValue5)
                 Else
                 value = CInt(sValuex)   
                  
                 sum = sum + value
                 If sum = 100 Then
                sscript3 = sscript3 & "'"
                Else
                 sscript3 = sscript3 & temp1 & ","
                 End If
                 End If

I am getting typemismatch when i am trying to use CInt function here.Can you give me some idea to help me out.
Thanks
Namish

larryperl 0 Light Poster
Private Sub CommandButton7_Click()

'UAD_FLG

    Dim sValue1 As String
    Dim sValue2 As String
    Dim sValue3 As String
    Dim sValue4 As String
    Dim sValuex As String
    Dim sscript As String
    Dim sscript2 As String
    Dim sscript3 As String
    Dim x As String
    Dim finalstring As String
    
    Dim temp1 As Integer
    
    
    
   
    Dim lRow As Long
    Dim lRowx As Long
    Dim lColValue1 As Long
    Dim lColValue2 As Long
    Dim lColValue3 As Long
    Dim lColValue4 As Long
    Dim lColValue5 As Long
    Dim stemp1 As String
    Dim sum As Integer
    
    Dim a As String
    
  
    
    
    '====================================
    'FLAG 1 CALL
    '====================================
    lRow = 3
    lColValue1 = 5
    lColValue2 = 11
    lColValue3 = 12
    lColValue4 = 13
    
     Call WriteToTextFile10("")
    Call WriteToTextFile10("---------UDA_FLG started")

       
    While Not Cells(lRow, lColValue1) = ""
        sValue1 = Cells(lRow, lColValue1)
        sValue2 = Cells(lRow, lColValue2)
        sValue3 = Cells(lRow, lColValue3)
        sValue4 = Cells(lRow, lColValue4)
        
        sscript = "INSERT INTO SYS_PARAMS(SECTION_NM,VARIABLE_NM, VARIABLE_VALUE, CREATE_ID, CREATE_DT, UPDATE_ID, UPDATE_DT) Values('UAD_FLG','"
         
        sscript2 = ",'P22919',SYSDATE,'', NULL);"
       temp1 = 0
      sum = 0
       
       For lRowx = 3 To 78
            For lColValue5 = 11 To 13
            sValuex = Cells(lRowx, lColValue5)
            If lColValue5 <> 13 Then
                If sValuex <> "" Then
                sscript3 = sscript3 & sValuex & ","
                 sValuex = Cells(lRowx, lColValue5)
                 Else
                 val = CInt(sValuex)
                 sum = sum + val
                 If sum == 100 Then
                sscript3 = sscript3 & "'"
                Else
                 sscript3 = sscript3 & temp1 & ","
                 End If
                 End If

I am getting typemismatch when i am trying to use CInt function here.Can you give me some idea to help me out.

Thanks
Namish

larryperl 0 Light Poster

Hi ...
I am totally new to vb programming.I have to do something like this for this i am not having any idea,kindly help me.

I have two excel files--
file one has data like thi---

601A 600 580 780 48 300 33
601B 600 580 780 48 300
601C 600 580 780 54 300 33
601D 560 580 780 48 300 33
603A 600 580 780 48 300 33
603B 600 580 780 48 300
603C 600 580 780 54 300 33
603D 560 580 780 48 300 33
614A 600 580 780 48 300 33
614B 600 580 780 48 300
614C 600 580 780 54 300 33
614D 560 580 780 48 300 33
615A 600 580 780 48 300 33
615B 600 580 780 48 300
615C 600 580 780 54 300 33
615D 560 580 780 48 300 33
There are so many values like this---

file 2 has---
601A PT UAD_FLG A1 33
601A PT UAD_FLG A2 33
601A PT UAD_FLG A3 34
601A PT TEST_FLG 1 50
601A PT TEST_FLG 2 50
601A PT BTMOD_FLG 5 10
601A PT BTMOD_FLG 6 10
601A PT BTMOD_FLG 7 80
601B PT TEST_FLG 1 50
601B PT TEST_FLG 2 50
601B PT BTMOD_FLG 5 10
601B PT BTMOD_FLG 6 10
601B PT …