我写了一个脚本,它会向用户邮件ID发送OTP(一次性密码)。因此,每当系统将OTP发送给用户时,我想启动1分钟的倒数计时器。但我不知道如何使用DCL Scripting启动倒计时器。任何想法?
下面是我用来生成OTP的脚本。但是我需要倒数计时器...是否可以在屏幕上显示倒计时? 请帮助!!
$! RAND - returns a positive random number ("RANDOM") between 0 and
$! __CEIL - 1.
$! sharris-at-sdsdmvax.fb3.noaa.gov
$ RAND:
$
$ IF F$TYPE(__SEED) .EQS. ""
$ THEN
$ ! seed the random number generator, ...
$ __NOW = F$CVTIME()
$ __HOUR = 'F$EXTRACT(11,2,__NOW)'
$ __MINUTE = 'F$EXTRACT(14,2,__NOW)'
$ __SECOND = 'F$EXTRACT(17,2,__NOW)'
$ __TICK = 'F$EXTRACT(20,2,__NOW)'
$
$ __SEED == __TICK + (100 * __SECOND) + (6000 * __MINUTE) + -
(360000 * __HOUR)
$ ! the generator tends to do better with a large, odd seed, ...
$ __SEED == (__SEED .OR. 1)
$ ! clean up, ...
$ DELETEX/SYMBOL __NOW
$ DELETEX/SYMBOL __HOUR
$ DELETEX/SYMBOL __MINUTE
$ DELETEX/SYMBOL __SECOND
$ DELETEX/SYMBOL __TICK
$ ENDIF
$
$ IF F$TYPE(__CEIL) .EQS. "" THEN __CEIL = %X3FFFFFFF
$
$ __SEED == __SEED * 69069 + 1
$ RANDOM == (__SEED.AND.%X3FFFFFFF)/(%X40000000/__CEIL)
$ define sys$output MANAGERS:[EMAL]random.txt
$ sh sym RANDOM
$ deassign sys$output
$ sear MANAGERS:[EMAL]random.txt random /out=MANAGERS:[EMAL]random1.txt
$ open in MANAGERS:[EMAL]random1.txt
$ LOOP4:
$ READ/END_OF_FILE=ENDIT4 IN RANDO
$ GOTO LOOP4
$ ENDIT4:
$ close in
$ RANDOM1 = F$EXTRACT(30,8,RANDO)
$ sh sym RANDOM1
$ mail a.txt smtp%"xx@x.com" /sub="Your Password is ''RANDOM1' "
当我运行上面的脚本时,我的OTP将如下:
Your Password is 1218A57A
答案 0 :(得分:0)
这是一个显示倒计时的基本DCL循环。正如其他人所说,它不会是60秒,但我猜这并不重要。
$ X = 60
$ 1$: WRITE SYS$OUTPUT X, " Seconds"
$ WAIT 00:00:01.00
$ X = X - 1
$ IF X .GT. 0 THEN GOTO 1$
$
如果从其他评论中不清楚,除非您出于某种原因将密码保存在random.txt文件中,否则您可以简化脚本的最后一位。而不是:
$ define sys$output MANAGERS:[EMAL]random.txt
$ sh sym RANDOM
$ deassign sys$output
$ sear MANAGERS:[EMAL]random.txt random /out=MANAGERS:[EMAL]random1.txt
$ open in MANAGERS:[EMAL]random1.txt
$ LOOP4:
$ READ/END_OF_FILE=ENDIT4 IN RANDO
$ GOTO LOOP4
$ ENDIT4:
$ close in
$ RANDOM1 = F$EXTRACT(30,8,RANDO)
$ sh sym RANDOM1
$ mail a.txt smtp%"xx@x.com" /sub="Your Password is ''RANDOM1' "
相反:
$ RANDOM1 = F$FAO("!XL",RANDOM)
$ mail a.txt smtp%"xx@x.com" /sub="Your Password is ''RANDOM1'"