----- Original Message -----
anyway, i can just ignore this issue right now.
the remaining issue is how to make my procedures automatically.
my purpose is to get trace ring buffer from kernel dump file and create a new
file which name is like trace_$date.txt. the $date should be the time this text file
is generated.
what i am doing now is to create a .crashrc file in the ./ directory, and try to
use file to make everything automatically. i need to make below procedures
automatically:
1. load trace.so automatically. it is ok now.
2. read current date. it is ok now.
3. dump the kernel trace ring buffer into new text file the name of which contains
current date. cannot do this now.
4. exit crash utility automatically. it is ok now.
my .crashrc is as below, i don't know how to do the step 3 above:
---------------------- script start
-------------------------------------------------------
echo $(date '+%Y%m%d_%H%M%S') <------ it is ok
#cur=$(date '+%Y%m%d_%H%M%S') <----- it failed to use variable to store date
#echo $cur <------it failed
extend trace.so <------ it is ok
trace report >./report_test.txt <------- to dump to a file which uses fixed file
name, it is ok.
trace report >./trace_$(date '+%Y%m%d_%H%M%S').txt <--- it failed when
exit
---------------------- script end -----------------------------------------------
please help, thanks.
For a shell command, you would need to precede the command with a "|" or
a "!". But the variable assignment would not persist, because each line
in the .crashrc (or any input file) is done as separate shell invocation.
For example, this input file has four separate shell invocations:
crash> !cat input
!cur=$(date '+%Y%m%d_%H%M%S'); echo $cur
!echo cur: $cur
|cur=$(date '+%Y%m%d_%H%M%S'); echo $cur
|echo cur: $cur
crash>
So the "echo" commands have no knowledge of the prior shell command's
setting of the "cur" variable:
crash> < input
20130121_112503
cur:
20130121_112503
cur:
crash>
And with respect to this:
crash> trace report >./trace_$(date '+%Y%m%d_%H%M%S').txt
When the command is invoked from within the crash utility, crash simply
opens a file with the name "./trace_$(date '+%Y%m%d_%H%M%S').txt", and
redirects the output to it. The crash utility does not do any kind of
parsing of the output file name for any embedded $(shell-cmd) or
`shell-cmd` usage.
Maybe you could do something like this in your .crashrc file:
trace_output
!ln trace_output $(date
'+%Y%m%d_%H%M%S')
extend trace.so
trace report
trace_output
!rm -f output
Dave