Operating System - HP-UX
1819833 Members
2870 Online
109607 Solutions
New Discussion юеВ

Re: Environment variables2

 
Rajkumar_3
Regular Advisor

Environment variables2

Hai all,

I need to pass two parameters:
a) The files stating with "X_" and
b) Retained time for deleting the renamed file (or) Retained time for deleting the non-renamed file.
(ie.,Time based)

Note: That means users will FTP from the remote server to the local server.So once the file is in the local server it will be renamed to "X_".

so If i pass the paramters like
variable1= X_ and time=1 (ie 1 hour)

It has to check the two conditions and file has to be deleted. I mean if i pass these above two parameters it has to satisfy the two conditions....

Is it possible like that to develop a shell script like that..

I have attached the document which i recieved from FAQ

Regards
Rajkumar
Oracle DBA
6 REPLIES 6
Rajkumar_3
Regular Advisor

Re: Environment variables2

Hai All,

I forgot to attach a document ..Please advise..

Is it possible to read those above mentioned paramters from the CONFIG file or INI file ???

Thanks for the advance inhelp..

Regards
Rajkumar
Oracle DBA
Thierry Poels_1
Honored Contributor

Re: Environment variables2

hi,
just a little note:
the find command parameters atime, ctime, mtime work with multiples of 24 hours (days) not with single hours!
So if you want to delete files after one or a few hours one small find statement will not be sufficient :(

regards,
Thierry.
All unix flavours are exactly the same . . . . . . . . . . for end users anyway.
Rajkumar_3
Regular Advisor

Re: Environment variables2

Hai All,

I forgot to attach a document..

Is it possible to collect the paramters from the CONFIG file or INI file and delete accordingly.

Please provide me a script..

I have attached a shell script that i recieved from the ROBIN....

Thanks from the advance in help...

Rajkumar
Oracle DBA
Rajkumar_3
Regular Advisor

Re: Environment variables2

Hai,

Thank you for your reply..

Yes you are correct..It works with multiple hours..

Is it possible to read the values (starting letter X or Y and hours) from the CONFIG file or INI file???
Because it was hardcoded in the config ir ini file..
Note: user may change the prefix X or Y.. and
hours =3 or 5 etc... or If it is not possible in hours it should be in seconds..

If the script can able to read those values from the config or ini file so it will work...

Can you provide me a script???

Thanks & Regards
Rajkumar



Oracle DBA
Robin Wakefield
Honored Contributor

Re: Environment variables2

Hi,

Yes, just create a script, say, ~/.config that says:

DAYS=3
VAR="X_"

In your main script, source this file:

. ~/.config

Then these variables will be set, so you could then say:

find $DIR -name "${VAR}*" -mtime +$DAYS ...

Rgds, Robin.
Wodisch
Honored Contributor

Re: Environment variables2

Hello Rajkumar,

if you want to get values from a CONFIG file into your script, there are many ways of doing this:

VALUE="$(grep '^PARAMNAME=' /you/config/file | cut -d= -f2-)"

seems to be a very simple and safe one.
Later in your script just refer to it as "$VALUE"...

HTH,
Wodisch