2007年6月19日星期二

function make bash works smooth

how to bind complex command of script & uniread into one?

function demosql() { script -t -c "uniread sqlplus $1" $2.log 2> $2.hms; }

this script will make out a function which works:

demosql hr/hr movetbs

the hr/hr is 1st parameter => $1 and movetbs is $2

that bind the uniread & script's power into a easy calling interface.
the output movetbs.log is for script contents and movetbs.hms for script timing.
the result should be played back with:

scriptreplay movetbs.hms movetbs.log

that can also be build into a playsql function:

function playsql() { scriptreplay $1.hms $1.log $2; }

the 1st parameter => $1 is movetbs and the 2nd is optional speed, so below command:

playsql movetbs 3

will playback at 3x speed :)

没有评论: