This content has been marked as final. Show 2 replies
1 person found this helpful
flaskvacuum wrote:The parts you've marked are simply formatting options for the date command:
i don't understand the bold parts.
FILE=ENTP_`date "+%d%m%y"`.dmp.Z LOG=ENTP_`date "+%d%m%y"`.log rm -f /tmp/exp_pipe */sbin/mknod /tmp/exp_pipe p*compress < /tmp/exp_pipe > $FILE | echo $PASS | exp ben@XEPROD tables=TBL_ABCD,TBL_EFGH,TBL_IJKLM_QWER triggers=n direct=y *file=/tmp/exp_pipe* log=$LOG rm -f /tmp/exp_pipe
The date command, along with its formatting options, is wrapped in backticks. This will fork a shell to run the subcommand, and substitute the shell's output (the output of the date command) into the containing string. That containing string is defining a variable. Taking the first example:
# date Tue Feb 7 17:26:49 PST 2012 # date '+%d' 07 # date '+%m' 02 # date '+%y' 12 # date '+%d%m%y' 070212 #
# echo $FILE # FILE=ENTP_`date "+%d%m%y"`.dmp.Z # echo $FILE ENTP_070212.dmp.Z #
what i know from /sbin is, anything that is put within there is for root command only. So my thinking, the above job can only executed in root enviroment.There are a number of utilities in /sbin that can be run as normal users, perhaps with a more restricted impact. That subdirectory just contains things that a normal user doesn't regularly need to have on their search path ($PATH).
the file part , what i understand is oracle exp / imp command and normally the file= will be like file=some.dmp . So now it become /tmp/exp_pipe which causes much confusion. Cos according to the declare variable, it should be file=$FILE.The named pipe being used in your example is to compress the output, thereby reducing disk space. Breaking the example down into a more simplistic example:
The mknod creates the pipe, compress reads FROM the pipe, and writes the compressed output TO $FILE. You could have put compress in the background with an ampersand, but simply suffixing it with a pipe has the same effect given that when "exp" is finished writing to the pipe (signaled by EOF), compress would return anyway. The end result is something like this:
bryan$ FILE=ENTP_`date "+%d%m%y"`.test.out.Z bryan$ echo $FILE ENTP_070212.test.out.Z bryan$ rm -f /tmp/exp_pipe bryan$ mknod /tmp/exp_pipe p bryan$ compress < /tmp/exp_pipe > $FILE | echo this is a simple test > /tmp/exp_pipe bryan$ ls -la $FILE -rw-rw-r--. 1 bryan bryan 27 Feb 7 17:46 ENTP_070212.test.out.Z bryan$ file ENTP_070212.test.out.Z ENTP_070212.test.out.Z: compress'd data 16 bits bryan$ zcat ENTP_070212.test.out.Z |more this is a simple test bryan$
exp command file=pipe_file --> compress reading FROM the pipe_file --> $FILE which is a *.Z file indicating it is compressed output.
Thank you so much for the details explanation.