<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 12pt;
font-family:΢ÈíÑźÚ
}
--></style></head>
<body class='hmmessage'><div dir='ltr'>thank you very much Dave, i have resolved this issue by using your code.<BR>your suggestion and explaination are very helpful.<br> <BR><div><div id="SkyDrivePlaceholder"></div>> Date: Mon, 21 Jan 2013 11:47:06 -0500<br>> From: anderson@redhat.com<br>> To: crash-utility@redhat.com<br>> Subject: Re: [Crash-utility] questions about crash utility<br>> <br>> <br>> <br>> ----- Original Message -----<br>> <br>> > anyway, i can just ignore this issue right now.<br>> > the remaining issue is how to make my procedures automatically.<br>> > my purpose is to get trace ring buffer from kernel dump file and create a new<br>> > file which name is like trace_$date.txt. the $date should be the time this text file<br>> > is generated.<br>> > what i am doing now is to create a .crashrc file in the ./ directory, and try to<br>> > use file to make everything automatically. i need to make below procedures <br>> > automatically:<br>> > 1. load trace.so automatically. it is ok now.<br>> > 2. read current date. it is ok now.<br>> > 3. dump the kernel trace ring buffer into new text file the name of which contains current date. cannot do this now.<br>> > 4. exit crash utility automatically. it is ok now.<br>> > <br>> > my .crashrc is as below, i don't know how to do the step 3 above:<br>> > <br>> > ---------------------- script start -------------------------------------------------------<br>> > <br>> > echo $(date '+%Y%m%d_%H%M%S') <------ it is ok<br>> > <br>> > #cur=$(date '+%Y%m%d_%H%M%S') <----- it failed to use variable to store date<br>> > #echo $cur <------it failed<br>> > <br>> > extend trace.so <------ it is ok<br>> > <br>> > trace report >./report_test.txt <------- to dump to a file which uses fixed file name, it is ok.<br>> > <br>> > <br>> > trace report >./trace_$(date '+%Y%m%d_%H%M%S').txt  <--- it failed when exit<br>> > ---------------------- script end -----------------------------------------------<br>> > <br>> > please help, thanks.<br>> <br>> For a shell command, you would need to precede the command with a "|" or<br>> a "!".   But the variable assignment would not persist, because each line<br>> in the .crashrc (or any input file) is done as separate shell invocation.  <br>> <br>> For example, this input file has four separate shell invocations:<br>> <br>>  crash> !cat input<br>>  !cur=$(date '+%Y%m%d_%H%M%S'); echo $cur<br>>  !echo cur: $cur<br>>  |cur=$(date '+%Y%m%d_%H%M%S'); echo $cur<br>>  |echo cur: $cur<br>>  crash><br>> <br>> So the "echo" commands have no knowledge of the prior shell command's<br>> setting of the "cur" variable:<br>> <br>>  crash> < input<br>>  20130121_112503<br>>  cur:<br>>  20130121_112503<br>>  cur:<br>>  crash> <br>> <br>> And with respect to this:<br>> <br>>  crash> trace report >./trace_$(date '+%Y%m%d_%H%M%S').txt<br>> <br>> When the command is invoked from within the crash utility, crash simply<br>> opens a file with the name "./trace_$(date '+%Y%m%d_%H%M%S').txt", and<br>> redirects the output to it.  The crash utility does not do any kind of<br>> parsing of the output file name for any embedded $(shell-cmd) or <br>> `shell-cmd` usage.<br>> <br>> Maybe you could do something like this in your .crashrc file:<br>> <br>>  > trace_output<br>>  !ln trace_output $(date '+%Y%m%d_%H%M%S')<br>>  extend trace.so<br>>  trace report > trace_output<br>>  !rm -f output<br>> <br>> Dave<br>> <br>> <br>> <br>> <br>> <br>> <br>> --<br>> Crash-utility mailing list<br>> Crash-utility@redhat.com<br>> https://www.redhat.com/mailman/listinfo/crash-utility<br></div>                                         </div></body>
</html>