Solved

how can i hide the password and also archive files with dates

Posted on 2014-04-21
7
151 Views
Last Modified: 2014-05-06
Need a change in below script:

1) Want to encrypt the mdmdbpwd password how can i do that
2) I have another folder /userin/dev/archive i want to archive 10 days worth of file there with time stamp too.

like
marketing_acct_em.ixf_20140421 and marketing_acct_em.log_20140421
marketing_acct_em.ixf_20140420 and marketing_acct_em.log_20140420
and so on for 10 days after 10 days it should be deleted

#!/bin/sh
#---- Set Environment
mdmdb="EMMDB"
mdmdbuser="MKT_DBO"
mdmdbpwd="time44up"
#-----PATH=$PATH:/db2_src/db2ruin/sqllib/bin
#------export PATH
. /db2_src/db2ruin/sqllib/db2profile

#---- Connect to the Database
db2 connect to $mdmdb user $mdmdbuser using $mdmdbpwd 

#
# Whatever you want to do goes here...
#
db2 "EXPORT TO
/userin/MAT_Integration_dev/marketing_acct_em.ixf OF IXF
MESSAGES
/userin/MAT_Integration_dev/marketing_acct_em.log
select 'x' as id  from SYSIBM.SYSDUMMY1"

	

#---- Terminate DB2
db2 terminate

Open in new window

0
Comment
Question by:sam2929
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 33

Expert Comment

by:ste5an
ID: 40012354
You don't gain any increase in security, cause you need the plain text password.

I'm not familiar with the command line tools of DB2, so an alternative may be using certifications instead. But this solution would be the same as placing your credentials in a separate file, so that you can share your script with others, just place the credentials file in your home.
0
 

Author Comment

by:sam2929
ID: 40012485
But this solution would be the same as placing your credentials in a separate file, so that you can share your script with others

Please tell me how can i do that

And also archive topic was not touched
0
 
LVL 19

Expert Comment

by:simon3270
ID: 40012733
For archiving, something like
find  /userin/dev/archive -mtime +10 -exec rm '{}' \;

Open in new window

will remove all files older than 10 days in that directory and any subdirectories.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:sam2929
ID: 40013329
what i need is archive then remove
0
 
LVL 19

Expert Comment

by:simon3270
ID: 40013563
For archive, to move a specific file to the archive directory, add this to the end of your script:

    cp /userin/MAT_Integration_dev/marketing_acct_em.log /userin/dev/archive/marketing_acct_em_$(date '+%Y%m%d_%H%M%S').log

That will copy the named file, add a timestamp (as YYYYMMDD_HHMMSS) to the name, and put it into the archive directory.

The archive removal line I gave earlier doesn't actually look at the time and date in the file name - it relies ion the "last modified" timestamp built into the file information.
0
 

Author Comment

by:sam2929
ID: 40024836
getting below error when i put delete ate end of script

#---- Delete files older then 10 days from archive folder

find  /userin/dev/archive/ -type f -mtime +10 -exec rm {}/
0
 
LVL 19

Accepted Solution

by:
simon3270 earned 500 total points
ID: 40025013
What error?

That's not what i wrote - the end of the "find" line should be:

    -exec rm '{}' \;

the single quotes round the {} stop the shell interpreting the braces, and the backslash before the ; does the same (no, I'm not sure why I use two different ways to protect text from the shell, but that just seems to be the way this style of command is always written!)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question