How do I meet while waiting for a script

I need to have access to the current date (or time) while waiting for the script so that I can add it to the directories created while waiting for the script, for example. something like this needs to be done

mkdir file<date> 

I can meet through the shell as

 date | tr " " "-" | cut -f 2,4 -d "-" 

However, I cannot access it while waiting, for example. can't do something like

 set var = `date | tr " " "-" | cut -f 2,4 -d "-"` 

I put this in a shell script and then echo it and get the output in $expect_out(buffer) as verbose here . However, the buffer also receives an invitation that must be deleted as indicated. Also note that $expect_out(buffer) does not really support what people want; it usually needs to be filtered out, at least to eliminate the prompt.

+6
source share
2 answers

While waiting, you used the built-in clock command:

 set now [clock seconds] set date [clock format $now -format {%b-%d}] set file file.$date 

Or at a time:

 set file file.[clock format [clock seconds] -format {%b-%d}] 

I would highly recommend you use a date format that sorts reasonably

 set file file.[clock format [clock seconds] -format {%Y-%m-%d}] 
+12
source

Cut from expected script:

 # set DATE variable in expect script set DATE [exec date +%F] send "This is test with expect on $DATE try 4\r" send ".\r" 
+1
source

Source: https://habr.com/ru/post/948831/


All Articles