1829536 Members
1806 Online
109992 Solutions
New Discussion

Re: Ask prompts

 
SOLVED
Go to solution
vmsserbo
Super Advisor

Ask prompts

How would I write up a procedure to have it ask for the Current day, 30 days or 60 days.

I want to be able to list backups logs with the current day , 30 days or 60 days listings?

Help!
So if I would choose option [C] for current I would only get 1 file for [30] 30 files for [60] 60 files. This is what I have so far?

$ read/prompt="[C]urrent, [30]days or [60]days " sys$command type



searchprod_admin:backup.log,backup.sav;* " ''thedate'",started/nowarn/noh^





14 REPLIES 14
Karl Rohwedder
Honored Contributor
Solution

Re: Ask prompts

Miles,

don't know if I got it right, but you seem to have a logfile BACKUP.LOG, which contains started messages for each backup.

To search for specific dates, you should construct the variable THEDATE, e.g. if TYPE = 30:
$ THEDATE = F$CVTIME("TODAY-''type'-0","ABSOLUTE","DATE")
You may then search with
$ SEARCH BACKUP.LOG "started","''THEDATE'" /Match=and/Remaining
which shows you all entries since the specified date.

To list the savesets you may use the DIRECTORY command together with /SINCE and /BEFORE.

Btw: I would not use a variable named TYPE, because that may conflict with the DCL verb TYPE.

regards Kalle
Hein van den Heuvel
Honored Contributor

Re: Ask prompts


Prompting for the date is easy enough, convertign that to a real date is easy enough alsocheck out:
$HELP LEXI F$CVTIME
$help dcl_tips date_time combination

Example:
$ show time
30-OCT-2006 11:36:03
$ write sys$output f$cvt("today -30-","absolute")
30-SEP-2006 00:00:00.00

however... SEARCH will only look for exact strings and will not understand 'since'.

Please explain in even more detail the exact problm you are tryign to solve and perhaps attach a text file with a sample of the backup log and what you would want to find in there with a given input selection.

You may need to DCL or PERL script to read each record, extract a date and compare.

Hope this helps some,
Hein van den Heuvel


vmsserbo
Super Advisor

Re: Ask prompts

Well what I want to do is this?

Have it ask first [D}etail or [S]ummary
If detail , I want to pull the backup info
from the backup.log and backup.sav;* files in prod_admin:

If summary, I want to pull it from Stats_dir:autodtat*.* files

Then I want it to ask for [C]urrent, 30day or 60 day. This is how many days from today they want to see the backup times for. I also want to give the Admin an Option of seeing it on the screen or printing it.

Thanks!!!


Jan van den Ende
Honored Contributor

Re: Ask prompts

Miles,

something along these lines:
.
.
.
Read_ds:
$ read sys$command DS /prompt="Detail or Summary?"
$ ds = f$extract(0,1,f$edit(Ds,"upcase,trim"))
$ If ds .eqs. "D" then goto detail
$ if ds .eqs. "S" then goto summary
$ Write sys$output " D or S !"
$ goto read_ds
.
. (similar for C_30_60)
. (similar for Screen_or_Print)
.
$ if C_30_60 .eqs. "C" then C_30_60 = 0
$ refdat = f$cvtim("today-''C_30_60'-,"absolute","date")
$
.
. processing from which enviroonment..
.
$ if screen_or_print .eqs. "S"
$ then
$ type/page/sin='refdat'
$ else
$ print /since ='refdat' .....
$ endif

You will have to do the formatting to your liking, and maybe add some more error handling, but this would be the general idea.

hth

Proost.

Have one on me.

jpe

.


$detail:
Don't rust yours pelled jacker to fine doll missed aches.
vmsserbo
Super Advisor

Re: Ask prompts

Great!

Thanks so much!!!!

vmsserbo
Super Advisor

Re: Ask prompts

I have attached a com file with it's output. I want it to do the same thing but given the options in my previous email!

Thanks!
vmsserbo
Super Advisor

Re: Ask prompts

Can someopne please loog at my attached com file. There seems to be an error with the time?

Hein van den Heuvel
Honored Contributor

Re: Ask prompts

Hmm, it seems you still have 'miles' to go!
Onfortunately you did not share enough information to exactly help you.
Specifically... where does the 'date' symbol come from (@DCL_SCREEN?) and what does it look like ($SHOW SYMB date)? Can it be changed?

The exact syntax for a combined date string is very critical and a little trick. be sure to experiment a lot with command recall and "$write sys$output f$cvtime(....".

You probably meant to write :
thedate=f$cvtime("''date' -00-","absolute","DATE")
Slightly more clear (IMHO) would be:

thedate=f$cvtime(date+ " -00-","absolute","DATE")

Now that menu option 2 and 3...

Is that going to set a range and then return to the menu. So the range will be called for example 'range'. Then the time code should probably look like:

thedate=f$cvtime("''date' -''range'-","absolute","DATE")

And you really should only assign 'thedate' in the common code, before the D/S split.

A more complete, but untested script, might look like:

:
$OPTION_0: $EXIT $OPTION_1:
$thedate=f$cvtime("''date' -''range'-","absolute","DATE") ! Unassigned range = 0
$ PUT "''SCR_L10'''SCR_BOLD'NOTE: choose D 0R S!''SCR_OFF'"
:
$ Write sys$output " D or S !"
$goto option_1
$ detail: :
summary:
:
$goto main_begin
$
$OPTION_2:
$read /prompt = "How many days old? " range
$! Validate range here
$goto option_1
$
OPTION_3: $read /prompt = "Which date" target-date
$! Validate target-date here
$date = target-date
$goto option_1

Good luck learning DCL!
Regards,
Hein.
Allan Bowman
Respected Contributor

Re: Ask prompts

Miles,

When you say Current, 30, or 60 days, are you expecting just a single day's dispaly? Or do you need all of the last 30 or 60 days? If you need all days, you will have to set up a loop within the procedure where you create date symbols for "-30","-29","-28", etc. (either a symbol for each date concatenated in the search string, or multiple searches one day at a time).

Allan
Robert Atkinson
Respected Contributor

Re: Ask prompts

Miles, another example attached that handles different input formats, verification, timeout, etc, etc. It's fully documented within the command file.

The usage would be :-

$ ASKYESNO == "@location:ASKYESNO.COM"
$ ASKYESNO "Please enter the date range 'C', '30' or '60'" "" "" 2 "C#30#60" "UPCASE"
Please enter the date range 'C', '30' or '60' > 55
%AYN-E-INVINPUT, Your input was invalid. Please try again
Please enter the date range 'C', '30' or '60' > 60

Robert.
Robert Atkinson
Respected Contributor

Re: Ask prompts

Oops!
vmsserbo
Super Advisor

Re: Ask prompts

I have attached teh logfiles that I will be searching?

Thanks!

vmsserbo
Super Advisor

Re: Ask prompts

This is what I have wriiten so far. I have attached a file that shows the com file, the results. I know I need to put a few more steps in there to produce the results I am looking for. I would hope that someone may modify my script to do just that.

Thanks!

Jan van den Ende
Honored Contributor

Re: Ask prompts

Miles,

instead of my bersion of this, let me give just my comments.
>>>>
$ NODE = F$GETSYI("NODENAME")
$ IF F$GETSYI("CLUSTER_MEMBER") THEN NODE=F$EXTRACT(0,5,NODE)
<<<<
What is your intention here? Nodenames can be up to 6 chars, but if you only want to use the 1st 5, then you achieve your goal. Otherwise, f$edit(node,"trim") will do better.
>>>>
$ SET PROC/PRIV=ALL
<<<<
I DETEST that, I really HATE it!.
I am of the opinion that privileges in VMS carry the wrong name. That name should be "RISK".
At the very least, the "ALL" should be removed from DCL systax, to have you/us take the trouble to enumerate all needed privs.
Find out what is needed, and enable ONLY those!
>>>>
.OR. (OPTION_NUM .GT. MAX_OPT)
<<<
Where does "max_opt" come from?
>>>>
thedate=f$cvtime(date+ " -00-","absolute
<<<
Syntax error. Replace with ("today+00-", ...
>>>
$ open/append outfile backup_save.tmp
$ close outfile
<<<
Please explain? As such this performs nothing. Maybe you still intend to add some activity, but until that...


But, all in all, things are growing!
Remember, HELP is always just a keyboard away. It would have told you some of the above much quicker!

Don't give up!

Proost.

Have one on me.

jpe
Don't rust yours pelled jacker to fine doll missed aches.