+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
erwa HowTo ShellScript - draft version - no
guarantee v01-02
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>set,
>debug, >trace
+----------------------------------------------------------------------------------------------------
in error
case it’s helpful to run the script in debug mode, using: “set –x”
+----------------------------------------------------------------------------------------------------
26.04.2006
+----------------------------------------------------------------------------------------------------
>header,
>program, >zai*net
+----------------------------------------------------------------------------------------------------
#!/bin/ksh
#:##################################################################################################################
#:
#: SCRIPTNAME: img2zn_newtrades
#:
#: VERSION,DATE: 1.00, 18.06.2001
#:
#: DESCRIPTION: upload new trades for interface
'Imagine' to 'Zai*Net'
#:
#:
AUTHOR: Erik Wagener,-5235,
IT Account IB, Zins/Devisen/Aktien
#:
#:
PROJECT: O2 (Fremdvergabe der Wertpapier- und
Derivateabwicklung)
#:
#: PARAMETERS: <database> <date>, e.g.:
img2zn_newtrades dbs 05May01
#:
#: EXAMPLE: img2zn_newtrades dbs 23Oct01
#:
#: CALLED BY: img2zn (shell script to control
process)
#:
#: SEQUENCE: img.newtrades.dat -> SQL_load
-> bnki07.4gl -> SQL_unload -> SQL_upltrd ->
#: makro BNKD1 -> makro BNKD2
-> SQL_pfact -> do_qdigit -> SQL_stat -> table 'tsf'
#:
#: USED SCRIPTS: start_xcom_upload (XCom transmission
script)
#:
#: USED MACRO/REPORTS: ETB-SMF/ETB-POS, ETB-PRM (reports to select
open positions)
#:
#: USED PROGRAMS: etb_smf.4ge (4gl program to convert
trades into the summit meta format)
#:
#: USED FILES: upload_prod.cnf (XCom configuration
file)
#:
#: RETURNCODE: 0: OK, 1: Error, no upload - try
again, 2: Error, partial upload - see rejected trades
#:
#: OS LEVEL SUPPORT: 4.2.1.0
#:
#: LAST CHANGES: 18.05.2001 (WAN) implementation
#:
#:##################################################################################################################
---------------------------------------------------------------------------------
2001
---------------------------------------------------------------------------------
Shell-Skript-Rahmen (Zai*Net) |
script |
|
#---------------------------------------------------------------------------------------------------- # The following lines must be the first ones in EACH
script #---------------------------------------------------------------------------------------------------- ME=`basename $0` . $ZNDIR/SCRIPTS/set_zainet_vars $ME PREFIX=$ME ############## Begin of Main Program
################################################################ #---------------------------------------------------------------------------------------------------- # Parameter #---------------------------------------------------------------------------------------------------- ARGC=$# DBIN=$1
#
database of zai*net to run on DATE=$2
# zai*net system date to run at #---------------------------------------------------------------------------------------------------- # Local Variables #---------------------------------------------------------------------------------------------------- . . . #---------------------------------------------------------------------------------------------------- # Test if another is already running #---------------------------------------------------------------------------------------------------- if [ -r $ZNTCH/$ME.running ]; then echo
"Another $ME is already running." exit 100 fi #---------------------------------------------------------------------------------------------------- # Write touch file to prevent multiple starting of
the scripts #---------------------------------------------------------------------------------------------------- touch $ZNTCH/$ME.running #---------------------------------------------------------------------------------------------------- # Write some starting status information to the log
file #---------------------------------------------------------------------------------------------------- . $ZNSTART $ME ... (Verarbeitung)) #---------------------------------------------------------------------------------------------------- # Write some ending status information to the log
file #---------------------------------------------------------------------------------------------------- rm $ZNTCH/$ME.running . $ZNFINISH $ME ##############
End of Main Program
################################################################## |
||
|
ShellScript |
|
>Input >Parameter, >getopts, >$#, ># |
$1; $2; $3 |
|
#------------------------------------------------------------------------------------------ #
Input parameter #------------------------------------------------------------------------------------------ DB=$1 DATUM=$2 INPPAR3=$3 . . . #-------------------------------------------------- # Uebergabe Parameter pruefen und sichern #-------------------------------------------------- if [[ $# -ne 3 ]]; then echo "Wrong params: get_db_euro
<mm/dd/yy> <database>" exit 1 fi while getopts t:d:f:h opt do case $opt in t)
TAG="$OPTARG";; d) DB_NEW="$OPTARG";; f) FLAG="$OPTARG";; h) echo
"usage: \n\tWas zu tun ist . . . " exit
0;; \?) echo
"Wrong params: Richtig ist . . . " exit 1;; esac done -------------------------------------------------------------------------------------------- while getopts
"i:o:p:e:d:s:t:l:r:?Hhv" option; do case $option in i) INPUT="${OPTARG}" ;; o) OUTPUT="${OPTARG}" ;; p) PRCMF="${OPTARG}" ;; e) ENVIR="${OPTARG}" ;; d) INP_DTE="${OPTARG}" ;; s) SPOT="${OPTARG}" ;; t) TAB="${OPTARG}" ;; l) DELIM="${OPTARG}" ;; r) RESRC="${OPTARG}" ;; v)
vers; exit 1 ;; ?|h|H) usage help; exit 1 ;; *) usage ; exit 1 ;; esac done -------------------------------------------------------------------------------------------- while getopts
:e:a:i:s:?Hh param; do case $param in e)
ENVIR=${OPTARG} ;; a)
DBUS_ADAPT=${OPTARG} ;; s)
START_STOP=${OPTARG} ;; i) INP=${OPTARG} ;; ?|h|H) usage ; desc ; vers ; exit 1 ;; *) usage ; desc ; exit 1 ;; esac done -------------------------------------------------------------------------------------------- if [[ ${0%%/*} == $0 ]];
then BINHOME="./" else BINHOME=${0%/*} fi |
||
|
ShellScript |
|
>Datum,
>Monat, >nächste Monat, >Wechsel, >Ende |
>date, >gdate, >expr |
|
date +%d/%m/%y,%H:%M:%S date +%d%b%y 20Nov07 date +%Y%m%d 20071120 #------------------------------------------------------------------------------------------ gdate +%Y%m%d
--date "+1 days" 20071121 gdate +%Y%m%d
--date "+10 days" 20071130 gdate +%Y%m%d
--date "+11 days" 20071201 #------------------------------------------------------------------------------------------ Usage: gdate
[OPTION]... [+FORMAT] or:
gdate [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] Display the
current time in the given FORMAT, or set the system date. -d, --date=STRING display time described by STRING,
not `now' %a
locale's abbreviated weekday name (Sun..Sat) %A
locale's full weekday name, variable length (Sunday..Saturday) %b
locale's abbreviated month name (Jan..Dec) %B
locale's full month name, variable length (January..December) %c
locale's date and time (Sat Nov 04 12:02:33 EST 1989) %C
century (year divided by 100 and truncated to an integer) [00-99] %d
day of month (01..31) %D
date (mm/dd/yy) %e
day of month, blank padded ( 1..31) %F
same as %Y-%m-%d %g
the 2-digit year corresponding to the %V week number %G
the 4-digit year corresponding to the %V week number %h
same as %b %H
hour (00..23) %I
hour (01..12) %j
day of year (001..366) %k
hour ( 0..23) %l
hour ( 1..12) %m
month (01..12) %M
minute (00..59) %n
a newline %N
nanoseconds (000000000..999999999) %p
locale's upper case AM or PM indicator (blank in many locales) %P
locale's lower case am or pm indicator (blank in many locales) %r
time, 12-hour (hh:mm:ss [AP]M) %R
time, 24-hour (hh:mm) %s
seconds since `00: %S
second (00..60); the 60 is necessary to accommodate a leap second %t
a horizontal tab %T
time, 24-hour (hh:mm:ss) %u
day of week (1..7); 1 represents
Monday %U
week number of year with Sunday as first day of week (00..53) %V
week number of year with Monday as first day of week (01..53) %w
day of week (0..6); 0
represents Sunday %W
week number of year with Monday as first day of week (00..53) %x
locale's date representation (mm/dd/yy) %X
locale's time representation (%H:%M:%S) %y
last two digits of year (00..99) %Y
year (1970...) #------------------------------------------------------------------------------------------ if [ -z "$DATUM" ]; then DATUM=`date +%d%b%y` DVALID=`date +%Y%m%d` else if [ `expr $DATUM : '.*\/'`
-ne 0 -o `expr $DATUM : '.*[A-Z]'` -ne 3 -o \ `expr $DATUM : '.*[a-z]'`
-ne 5 -o `expr $DATUM : '[0-9]*'` -ne 2 ]; then echo "Usage: \"$ME
database date interfaceid recordtype\"" echo " e.g. \"$ME dbs 23Oct01 IZNSUPOS IZNSUPOS
>>$ZNDIR/LOG/etb_pos_smf.log 2>&1\"" exit else if [ `expr $DATUM : '.*'`
-ne 9 -a `expr $DATUM : '.*'` -ne 7 ];
then # echo "Wrong date
format! It should be like e.g. \"18Mar02\"." echo "Usage:
\"$ME database date interfaceid recordtype\"" echo " e.g. \"$ME dbs 23Oct01 IZNSUPOS IZNSUPOS
>>$ZNDIR/LOG/etb_pos_smf.log 2>&1\"" exit else # convert it to header
validity date format DVALID=`convDateZnSys
$DATUM` fi fi fi #------------------------------------------------------------------------------------------ if [ "`gdate
--date=$DTEDTE +%a`" = "Fri" ]; then . . . fi |
||
|
ShellScript |
|
Funktion innerhalb der Shell |
>function |
|
#------------------------------------------------------------------------------------------ # Function (always at the beginning of the
shell script to be declare) #------------------------------------------------------------------------------------------ FunctionName() { InputParameter=$1 ... OutPutParameter="$Jahr$Monat$Tag" echo
$OutPutParameter } |
||
|
ShellScript |
|
Variablensubstitution, Vorkommastellen, Nachkommastellen |
>echo |
21.02.02 |
PPRC1=`echo "${PPRC%%\.*}"` # Vorkommastellen: Alles rechts vom
Muster \. also '.' wird gelöscht
PPRC2=`echo
"${PPRC##*\.}"` #
Nachkommastellen: Alles links vom Dezimalpunkt wird gelöscht |
||
|
ShellScript |
|
>return code,
Rückgabewert, >$?, >?
|
>rc |
2007
|
RC1=$? if [ $RC1 -ne 0 ]; then display_log "Erroneous processing with
return code '$RC1' - will terminate, please check" exit 1 else display_log
"Successfully processed - will continue . . . " fi |
||
|
ShellScript |
|
Hilfsfunktion für Ausschrieb, >date, >log, >procedure
|
>display_log |
2007
|
display_log() { if [[ ${#}
-eq 0 ]]; then echo
>> ${LOG_DIR}/${LOG_FIL} 2>&1 else echo
"`date '+%d.%m.%Y %H:%M:%S'` <${ME}> : ${*}" >>
${LOG_DIR}/${LOG_FIL} 2>&1 fi return } |
||
|
ShellScript |
|
chown,
&& |
>chown |
|
files="SV_FX.TXT
SV_WOFX.TXT SV_FX_FF.TXT SV_WOFX_FF.TXT SV_FLEX.TXT SV_FLEX_FF.TXT" dir=/opt/curplus/$envdir target=$TOOLVAR/ksfi/last cd $dir chown
curplus:curplus $files cp -p $files
$target && rm -f $files |
||
|
|
|
chmod, >rights, >Rechte |
>umask |
29.06.005 |
0.) Bei
Ausführung eines Skriptes fehlen die notwendigeb Rechte, z.B. ein Verzeichnis
anzulegen oder in ein Verzeichnis schreiben zu dürfen. |
||
|
ShellScript |
|
Überprüfung Eingabeparameter, z.B. Datenbank |
>test, -n, >expr |
|
#------------------------------------------------------------------------------------------ # Get the database parameter and check, if it
exists #------------------------------------------------------------------------------------------ [ -n
"$DB" ]; then if [
\( `expr $DB : '.*'` -eq 3 -o `expr $DB : '.*'` -eq 4 \) -a `expr $DB :
'[a-z]*'` -eq 3 ]; then
ZNDBS=$DB else
echo "Usage: \"$ME database date itfid recordtype
>>$ZNDIR/LOG/etb_pos_smf.log 2>&1\""
echo " e.g. \"$ME dbs
exit fi fi |
||
|
ShellScript |
|
Überprüfung Eingabeparameter, z.B. Datum |
>test -z |
|
#---------------------------------------------------------------------------------------------------- # Get the validity date and check the format #---------------------------------------------------------------------------------------------------- if [
-z "$DATUM" ]; then
DATUM=`date +%d%b%y`
DVALID=`date +%Y%m%d` else if [
`expr $DATUM : '.*\/'` -ne 0 -o `expr $DATUM : '.*[A-Z]'` -ne 3 -o \ `expr $DATUM : '.*[a-z]'` -ne 5 -o
`expr $DATUM : '[0-9]*'` -ne 2 ]; then
echo "Usage: \"$ME database date interfaceid recordtype
>>$ZNDIR/LOG/etb_pos_smf.log 2>&1\""
echo " e.g. \"$ME dbs
23Oct01 IZNSUPOS IZNSUPOS >>$ZNDIR/LOG/etb_pos_smf.log
2>&1\""
exit else if
[ `expr $DATUM : '.*'` -ne 9 -a `expr $DATUM : '.*'` -ne 7 ]; then #
echo "Wrong date format! It should be like e.g.
\"18Mar02\"."
echo "Usage: \"$ME database date interfaceid recordtype
>>$ZNDIR/LOG/etb_pos_smf.log 2>&1\""
echo " e.g. \"$ME dbs
23Oct01 IZNSUPOS IZNSUPOS >>$ZNDIR/LOG/etb_pos_smf.log
2>&1\""
exit
else #
convert it to header validity date format
DVALID=`convDateZnSys $DATUM` fi fi fi |
||
|
ShellScript |
|
Definition
lokale Variable
|
|
|
#---------------------------------------------------------------------------------------------------- # Define local variables #---------------------------------------------------------------------------------------------------- ETB_PROG="etb_smf.4ge" # 4gl program to
transform fx options into summit meta format REM_FILE="betb.bpjob.bwpat012"
# remote file which is
transferred to the bnkenheim-host prod SMF_FILE=$ZNWRK/${PREFIX}.smf
# zainet fx options file in
summit meta format LOG_FILE=$ZNLOG/${PREFIX}.log # log file which is displayed by
tail_term in log-dir. TMP_FILE=$ZNWRK/${PREFIX}.tmp
# temporary file TRS_FILE=$ZNWRK/${PREFIX}.transfer # name of file to be transferred to the bnkenheim
host PAK_FILE="$ZNWRK/../${PREFIX}.packno" # file for counting the package number ... SAV_DIR=$ZNSAV/ETB # Save directory path ZNWRK="$ZNDIR/ETB/SMF" # working directory
path TIME_DELAY1=600 # look for first receipt file Q1
after ten minutes ... RSH=/usr/bin/rsh # remote shell command RCP=/usr/bin/rcp # remote copy command FIND=/usr/bin/find # find command ISQL=$INFORMIXDIR/bin/isql # informix command to execute SQL
statement ... XCOMDIR=summit # dir of zainet summit transfer
files XCOMUSER=remcop # name of XCom user XCOMSERVER=xcom_zainet # name of XCom server XCOM_ZAINET=/XCOM2000/zainet # dir of zainet on the XCom
server XCOM_UPLOAD=$XCOM_ZAINET/scripts/start_xcom_upload # script to transfer by xcom IMG_USER=zainet # imagine
user IMG_PASSWD=zeus #
imagine password IMG_SERVER=oftzai05 #
imagine server to get trades from IMG_SVR_DIR=$ZNDIR/IMG2ZN/DATA # imagine directory STOTRADE_PATT=img.storni.*.dat # storno file
pattern NEWTRADE_PATT=img.newtrades.*.dat # new trade file
pattern IMG_STO_PATT=$TRANSFER_DIR/$STOTRADE_PATT # storno data file at transfer
directory IMG_NEW_PATT=$TRANSFER_DIR/$NEWTRADE_PATT # new trade data file at
transfer directory CNF_FILE=upload_prod.cnf # config file of XCom transfer . . . |
||
|
ShellScript |
|
Start Zai*Net Makro |
>macro |
|
show_log "Loading in 'tsf' with first
keyboardmakro: 'BNKD1' started for $DATE . . . " $ZNDIR/zsi/act_version.zt -d$ZNDIR/dbs/$DBS
-m"BNKD1" -tDATE RC=$? if [ $RC != 0 ]; then show_log "Error loading into 'tsf' by 'BNKD1'
($RC).\n" end_log exit 2 else show_log "Loading into 'tsf' by 'BNKD1'
successfully finished ($RC).\n" fi oder . . . #---------------------------------------------------------------------------------------------------- #
Zai*Net Makro to start the Zai*Net Batch / Reports #---------------------------------------------------------------------------------------------------- echo "Running ZAI*NET macro 'ETB-SMF'
at" `date +"%H:%M:%S"` "for" $DATUM $ZNDIR/zsi/act_version.zt -d$ZNDIR/dbs/$ZNDBS
-mETB-SMF -s -t$DATUM if [ $? != 0 ]; then echo
"An error occured in the ZAI*NET macro 'ETB-SMF'." exit
54 fi echo "Done ZAI*NET macro 'ETB-SMF'
at" `date +"%H:%M:%S\n"` oder . . . #---------------------------------------------------------------------------------------------------- # Run the macro now #---------------------------------------------------------------------------------------------------- echo "Using command
\"$ZNDIR/zsi/act_version.zt -d$ZNDIR/dbs/$ZNDBS -m$MACRO -s\"
..." echo "Beginning at" `date
+"%H:%M:%S"` $ZNDIR/zsi/act_version.zt -d$ZNDIR/dbs/$ZNDBS
-m$MACRO -s if [ $? != 0 ]; then echo
"An error occured during the ZAI*NET macro $MACRO." exit
1 else echo
"ZAINET macro $MACRO finished successfully." fi echo "Finished at" `date
+"%H:%M:%S"` |
||
|
ShellScript |
|
Ausführen eines 4gl-Programms |
>4gl |
|
TRDUPL4GL=$FOURGL_DIR/bnki07.4ge # 4gl program to
prepare trade upload . . . #################################################################################################################### #
start prepare trade in 'ximgupl' before writing to 'zainet.upl':
convert to zai*net logic and set default values #################################################################################################################### show_log "Starting 4gl program
'$TRDUPL4GL' to .. " show_log ".. convert records to zai*net
logic and set default values . . . " cd $FOURGL_DIR $TRDUPL4GL $DBS RC=$? if [ $RC != 0 ]; then show_log "Error by running the 4gl
program '$TRDUPL4GL'. Exiting the script ($RC).\n" end_log exit 1 else show_log "4gl program '$TRDUPL4GL'
successfully finished ($RC).\n" fi oder . . . #---------------------------------------------------------------------------------------------------- # 4gl-program
to transform the Zai*Net data from the table into the Summit Meta Format file #---------------------------------------------------------------------------------------------------- echo "Running 4GL '$ETB_PROG' at" `date
+"%H:%M:%S"` TERM=vt100 $ZNDIR/ETB/$ETB_PROG -d$ZNDBS -f`basename $SMF_FILE`
-p$ZNWRK -r$RECORDTYPE 1> /dev/null rc=$? if [ $rc != 0 ]; then echo
"The 4GL etb_smf returned the following rc: $rc." exit 55 fi echo "Done 4GL '$ETB_PROG' at" `date
+"%H:%M:%S\n"` |
||
|
ShellScript |
|
Ausführen SQL-Statement (Zai*Net - Informix) |
>SQL |
|
FIND=/usr/bin/find ISQL=$INFORMIXDIR/bin/isql # Tabelle
TabellenNamen leeren ( $ISQL
$ZNDIR/dbs/dbs - <<EMPTY_TABLE begin work; delete from
TabellenNamen where 1=1; commit work; EMPTY_TABLE ) # Unload Tabelle 'TabellenNamen' in Unloadfile
'UnloadFileName' ( $ISQL $ZNDIR/dbs/dbs - <<UNLOAD_TABLE begin work; unload to
$ZNDIR/admin/WAN/UnloadFileName.unl select * from TabellenNamen; commit work; UNLOAD_TABLE ) # Load unload file into table ( $ISQL $ZNDIR/dbs/dbs - <<LOAD_TABLE begin work; load from
$ZNDIR/admin/WAN/UnloadFileName.unl insert into TabellenNamen; commit work; LOAD_TABLE ) # Insert in Tabelle 'TabellenName1' SQL="insert into TabellenName \ select
'$DATUM', '$ZEIT', book_pc, trader, usage, line, pct \ from TabellenName2 \ where
book_pc != 'VAR-PC'
" ( $INFORMIXDIR/bin/isql
$DB - <<FERTIG $SQL FERTIG ) 1>/dev/null 2>&1 # Update in Tabelle 'top' SQL_UPDATE="update top set top_strike = $STRIKE
where top_cpty = '$CPTY' \
and top_comp1 = '$COMP1' and top_comp2 = '$COMP2' \
and top_amtcode = '$AMTCODE'" $ZNSCR/exec_sql_stmt $ZNDIR/dbs/$ZDBS
"$SQL_UPDATE" if [[ $? != 0 ]]; then exit –1 fi # SQL_TNUM="select tstatus_tnum from tstatus, top where
tstatus_new > 5 \
and top_tnum = tstatus_tnum
\
and tstatus_tnum != ''
\
and tstatus_new not between 8388608 and 8388609 \
and tstatus_new != 261
\ and
(tstatus_adate = '$TAG' and
tstatus_atime >= $ZEIT )
union
select tstatus_tnum from
tstatus, top where tstatus_new > 5 \
and top_tnum = tstatus_tnum
\
and tstatus_tnum != ''
\
and tstatus_new not between 8388608 and 8388609 \
and tstatus_new != 261
\
and (tstatus_adate > '$TAG'
and tstatus_adate < '$LZ_TAG' ) union
select tstatus_tnum from
tstatus, top where tstatus_new > 5 \
and top_tnum = tstatus_tnum
\
and tstatus_tnum != ''
\
and tstatus_new not between 8388608 and 8388609 \
and tstatus_new != 261
\
and (tstatus_adate = '$LZ_TAG' and tstatus_atime < $LZ_ZEIT )" TNUM=`$ZNSCR/exec_sql_stmt $ZNDIR/dbs/$DB
"$SQL_TNUM"` if [ "$TNUM" = "empty" ] then ... exit fi # Data for limit table will be unloaded in 3 files ( $INFORMIXDIR/bin/isql $ZNDIR/dbs/$ZNDBS -
<<LIMIT_TOP { begin work; unload to $ZNDIR/TMP/limit_cpty_top_ds.unl select
'CPTY', top_cpty, 'NET', 'D/S GROSS', 0, 0, '' from top where top_cpty not in (select limit_name from limit) and top_cpty not in (select cpty_cpty from cpty
where cpty_type = 'M' or cpty_type = 'H') group by top_cpty; commit work; begin work; unload to $ZNDIR/TMP/limit_cpty_top_mt.unl select
'CPTY', top_cpty, 'NET', 'MATURITY', 0, 0, '' from top where top_cpty not in (select limit_name from limit)
and top_cpty not in (select cpty_cpty from cpty
where cpty_type = 'M' or cpty_type = 'H') group by top_cpty; commit work; } ... LIMIT_TOP ) |
||
Beachten:
Diese Befehle müssen immer linksbündig stehen !!! |
ShellScript |
|
Sybase isql Abfrage mit Parameter-Rückgabe |
>isql |
|
n=$(
$SYBASE/$SYBASE_OCS/bin/isql -D rco_yest -U${DBUSER} -P${DBPAZZ}
-b<<_EOF set nocount on go select count(*) from rco_yest..REPBATCH#BO#MXPL_DBF go _EOF ) anstatt (was auf
Server mit unterschiedlichen Shell nicht gültig sein kann) n=`$SYBASE/$SYBASE_OCS/bin/isql
-D rco_yest -U${DBUSER} -P${DBPAZZ} -b<<_EOF set nocount on go select count(*) from
rco_yest..REPBATCH#BO#MXSTAT_DBF go _EOF` |
||
|
ShellScript |
|
Existenz Datei überprüfen |
test –r; test –s |
|
if [ -r $FileName -a -s $FileName ]; then echo
"The File '`basename $FileName`' was successfully written\n" ... else echo
"The File '`basename $FileName`' on '$TargetPath' doesn't exist\n" ... fi ($FileName
beinhaltet in diesem Beispiel sowohl den Pfad als auch den Dateinamen) |
||
|
ShellScript |
|
>Stringvergleich, >[[, >]], >else, >elif
|
>test, >if, >-z
|
|
if [ ! -z "$TIDDDF" ] && [ ! -z
"$TIDMXG" ] && [[ "$TIDDDF" >
"$TIDMXG" ]]; then . . . else . . . fi -------------------------------------------------------------------------------------------- if [[ $# != 1 ]] && [[
"${SECPARAM}" != "A" ]]; then echo
"usage: startAdaptor.ksh <property.environment.props>" exit 1 fi -------------------------------------------------------------------------------------------- if [[ "${PARAM01}" = "string01"
]] && [[ "${PARAM02}" = "pattern02" ]]; then . . . elif [[ "${PARAM01}" = "string01"
]] && [[ "${PARAM02}" = "pattern03" ]]; then . . . elif [[ "${PARAM01}" =
"string02" ]] && [[ "${PARAM02}" = "pattern02t"
]]; then . . . fi -------------------------------------------------------------------------------------------- if [[ $# != 1 ]] || [[ "$1" =
"-h" ]] || [[ "$1" = "help" ]] || [[
"$1" = "h" ]]; then . . . fi -------------------------------------------------------------------------------------------- if [ -n
"${INP_DTE}" ]; then . . . fi -------------------------------------------------------------------------------------------- [ -s ${DIR01}/file01_${DATUM}.csv
] && rm ${DIR01}/file01_${DATUM}.csv [ -z ${NEW_DIR} -o ! -d ${NEW_DIR} ] && echo
"input dir '${DIR}' not found ! Please check !" [[ ! -d $PIDDIR ]] && mkdir $PIDDIR [[ -f $LHOME/etc/dbus.profile ]] && . $LHOME/etc/dbus.profile -------------------------------------------------------------------------------------------- if [ -n "${DBUS_DIR}" -a -d ${DBUS_DIR} -a
-s ${DIR}/${ADAPT}.props.template ]; then cd ${DIR}
ADP_DIR=`pwd` elif [ ! -d ${DIR} -o ! -s ${DIR}/${ADAPT}.props.template
]; then echo
"error: adaptor directory '${ADP_DIR}' not found - will terminate!" exit 1 fi -------------------------------------------------------------------------------------------- [ -n
"$DB" ]; then if [
\( `expr $DB : '.*'` -eq 3 -o `expr $DB : '.*'` -eq 4 \) -a `expr $DB :
'[a-z]*'` -eq 3 ]; then
ZNDBS=$DB else
echo "Usage: \"$ME database date itfid recordtype
>>$ZNDIR/LOG/etb_pos_smf.log 2>&1\""
echo " e.g. \"$ME dbs
exit fi fi |
||
muss
dbnkelt geklammert werden |
ShellScript |
|
>Drucker, >printer, >queue
|
>lpstat |
|
1.) lpstat -o 2.) lpstat -p 3.) lpstat -o pj128 FFTUSP7730:/home/f985757$ lpstat -o pj128 => Hängt dann offensichtlich seit zwei Tagen . . . => 'infrastructure' #69720 (Hotline) anrufen, den
'print service' zu restarten |
||
|
ShellScript |
|
Maximale Recordlänge einer Datei bestimmen |
>read, >exec |
|
#---------------------------------------------------------------------------------------------------- # Get record size #---------------------------------------------------------------------------------------------------- if [ $Flag –eq 1 ] # Daten vorhanden then tmp=0 maxrecl=0 exec 3<$FileName while read -u3 zeile do tmp=`echo $zeile | wc -c` if [ $tmp -gt $maxrecl ]; then
maxrecl=$tmp; fi done
exec 3<&- maxrecl=`expr $maxrecl + 3` # eigentlich 4 letztes Zeichen in Zeile
ist "\n" daher 3 maxrecl=`expr $maxrecl \* 1`
blksize=`expr $maxrecl \* 5` fi |
||
|
ShellScript |
|
Datei zeilenweise einlesen/verarbeiten |
>exec,>read,>cat |
27.08.01 |
|
exec
3<$FileName while read
–u3 zeile do tmp=`echo
$zeile` ... done exec
3<&- oder cat
$REPORT_FILE | while read zeile do tnum=`echo
$zeile | cut -d\| -f2` . . .
done |
|||
Dateideskriptor |
ShellScript |
|
|
Packetnummer aus Datei lesen / hochzählen |
>read, >exec |
|
typeset –RZ7 PACKNO if [ -s $PAK_FILE ] then exec
3<$PAK_FILE read –u3
PACKNO else PACKNO=1 fi ... PACKNO=`expr $PACKNO + 1` echo
$PACKNO > $PAK_FILE |
||
|
ShellScript |
|
Remote Copy per Shell
Script
|
>rcp |
|
RCP=/usr/bin/rcp # remote copy
command ... XCOMDIR=summit
#
dir of zainet summit transfer files XCOMUSER=remcop # name of XCom
user XCOMSERVER=xcom_zainet # name of XCom server XCOM_ZAINET=/XCOM2000/zainet # dir of zainet on the Xcom server XCOM_TRANS_FILE=$XCOM_ZAINET/$XCOMDIR/zai_sum_pos.dat #
transfer file ! Namenskonvention ! ... #---------------------------------------------------------------------------------------------------- # Remote copy of the transfer file to the
XCOM-Server #---------------------------------------------------------------------------------------------------- echo "Remote Copy from '`basename $TRS_FILE`'
to '$XCOM_TRANS_FILE' starting" $RCP $FileName
$XCOMUSER@$XCOMSERVER:$XCOM_TRANS_FILE if [ $? != 0 ] then echo
"Remote Copy from '/`basename $TRS_FILE`' to '$XCOM_TRANS_FILE'
failed" $ERROR_CHECK
26 $ME exit 100 else echo
"Remote Copy from '`basename $TRS_FILE`' to '$XCOM_TRANS_FILE'
successful" fi |
||
|
ShellScript |
|
Remote Shell zur Dateiübertragung |
>rsh |
|
#---------------------------------------------------------------------------------------------------- # Remote
shell to transmit the file to the host #---------------------------------------------------------------------------------------------------- echo
"\nTransfer of '$XCOM_TRANS_FILE' to '$REM_FILE' starting" RC=`$RSH
$XCOMSERVER -l $XCOMUSER $XCOM_UPLOAD $CNF_FILE $XCOM_TRANS_FILE
\"$REM_FILE\" $maxrecl $blksize` # Restl Param sind in Config-Datei
bestimmt! Achtung: Hier uebergebene Parameter sind dominant! if [ $RC != 0
]; then $ERROR_CHECK 33 $ME if [ $? != 0 ]; then echo "Transfer of '$XCOM_TRANS_FILE'
to '$REM_FILE' failed" exit 100 fi else echo "Transfer of '$XCOM_TRANS_FILE'
to '$REM_FILE' successful" $RSH
$XCOMSERVER -l $XCOMUSER rm \"$XCOM_TRANS_FILE\" fi |
||
|
ShellScript |
|
Remote Shell Zielrechner-Konfiguration |
>rsh, >rhosts |
|
Um
auf einen anderen Unix-Rechner 'Remote-Server' etwas per remote shell 'rsh'
als User ausführen zu können, muß dort im Home-Verzeichnis dieses Users in
der Datei '.rhosts' der eigene Unix-Rechner inklusive eigener User
eingetragen sein. Alles klar?! Bsp.: Um von Zai*Net aus per remote shell 'rsh' die
Reuters-Kurse per 'rip.sh' abzufragen, muß dort auf dem 'ripserver' unter dem
user 'ripadm' in der Datei '.rhosts' die Zai*Net-Rechner 'ofszai03',
'ofszai04' und 'oftzai05' für die user 'zainet' und 'zntek' eingetragen sein.
rsh ripserver -l ripadm /soft/triarch/RIP/rip.sh
/soft/triarch/RIP/cfg/ZNPFF.CFG [ofsdis04]
/home/tek/ffm/ripadm> ls -l .rhosts
-rw------- 1 ripadm
uvp 342 Dec 5
|
||
|
ShellScript |
|
Dateien wegsichern und komprimieren |
>mv,>compress |
|
#-----------------------------------------------------------------------------------------#
Save, compress and remove files #----------------------------------------------------------------------------------------- if [ -r $TRS_FILE -a -s $TRS_FILE ]; then mv $TRS_FILE
$SAV_DIR/`basename $TRS_FILE`.$DATUM compress -f
$SAV_DIR/`basename $TRS_FILE`.$DATUM if [ -r
$SMF_FILE -a -s $SMF_FILE ]; then rm -f
$SMF_FILE fi fi |
||
|
ShellScript |
|
no hangup Prozesse im Hintergrund starten |
>nohup |
|
#----------------------------------------------------------------------------------------- # Starting scripts to look for receipt files on XCom
with time delay #----------------------------------------------------------------------------------------- nohup $ZNDIR/ETB/etb_pos_rec Q1 $TIME_DELAY_Q1
>> $ZNDIR/LOG/$ME.log & nohup $ZNDIR/ETB/etb_pos_rec Q2 $TIME_DELAY_Q2
>> $ZNDIR/LOG/$ME.log & (no hangup
bedeutet, daß die Prozesse auch dann weiterlaufen, wenn z.B. die Shell
geschlossen wird ...) |
||
|
ShellScript |
|
Datenfeld Trennzeichen manipulieren |
>ifs |
|
IFSVORH=$IFS
# notice the original field seperator IFS=""
# set field seperator to empty string ... IFS=$IFSVORH
# set the original field seperator (Wenn
Strings zusammengesetzt werden zum Ausschliessen von Nebeneffekten
(Leerzeichen, Zeilenschaltungen, ...)) |
||
|
ShellScript |
|
>host, >server, >name |
>uname |
02.05.2005
|
FFTUSB7730:/home/f985757$ uname -n FFTUSB7730 |
||
|
ShellScript |
|
Start eines Skriptes per Remoteshell und Rückgabeabfrage |
case, >rsh, >rcp |
|
ME=`basename
$0` #
Name selbst des laufenden Skripts Q1OR2=$1
#
Parameter Q1 or Q2 TWAIT=$2
#
Parameter time to wait ... RSH=/usr/bin/rsh #
Remote Shell RCP=/usr/bin/rcp #
Remote Copy ... XCOMSERVER=xcom_zainet # name
of Xcom server XCOMUSER=remcop #
name of Xcom user XCOM_ZAINET=/XCOM2000/zainet # dir of
zainet on the XCom server XCOM_SCRIPT=$XCOM_ZAINET/scripts/look_for_receipts # script to look for receipt files ... #---------------------------------------------------------------------------------------------------- # Start script on XCom server to look for receipt
files (Quittungsdateien) #---------------------------------------------------------------------------------------------------- Risiko Controlling =`$RSH $XCOMSERVER -l $XCOMUSER
$XCOM_SCRIPT $Q1OR2 $TWAIT` #---------------------------------------------------------------------------------------------------- # Write in case of found receipt file into the
ALL.log log file #---------------------------------------------------------------------------------------------------- zndate=`date +"%d%b%y, %H:%M"` Machine=`hostname` case "$RC" in
"OKQ1")
$ZNDIR/SCRIPTS/echo_log "$zndate: Machine: $Machine, $ME INFO:
Receipt file 'zai_sum_pos.Q1' from e.t.b received." $ZNDIR/LOG/ALL.log ;;
"NOQ1")
$ZNSCR/error_check 141 "$ME Q1" ;;
"OKQ2")
$ZNDIR/SCRIPTS/echo_log "$zndate: Machine: $Machine, $ME INFO:
Receipt file 'zai_sum_pos.Q2' from e.t.b received." $ZNDIR/LOG/ALL.log ;;
"NOQ2")
$ZNSCR/error_check 142 "$ME Q2" ;;
"ERRQ2")
$ZNSCR/error_check 140 "$ME Q2" ;;
"ERRPAR") echo
"Wrong parameter for 'look_for_receipts'" ;; "*") ;; esac |
||
|
ShellScript |
|
Import Parameter |
>case |
25.08.03 |
case $1 in -u|-user|-usr|u|user|usr) echo support ;; -p|-password|-pwd|p|password|pwd) echo support ;; *) echo "Undefined arguments:
$1" echo "Try options -u or
-p for user or password." echo "Example: dbuser
-u" ;; esac case
"$1" in start) start_olk_server sleep 2 start_import_server
sleep 2 start_monitor start_import_session ;; stop) stop_monitor stop_import_server stop_import_session stop_olk_server ;; status) write_log " " write_log " " write_log " " write_log " " write_log " " write_log " " ;; restart) stop_monitor stop_import_server stop_import_session stop_olk_server sleep 2 start_olk_server sleep 2 start_import_server sleep 1 start_monitor start_import_session ;; startsession) start_import_session ;; stopsession) stop_import_session ;; startserver) start_import_server sleep 1 start_monitor ;; stopserver) stop_monitor stop_import_server ;; start_olk) start_olk_server ;; stop_olk) stop_olk_server ;; -v) echo "Program: $0, Version:
$VERSION" exit 0 ;; -h) echo "Usage: $0 [-v] [-h] start |
stop | restart | status | startserver | startsession | stopserver |
stopsession" exit 0 ;; "") echo "Missing parameter" echo "Usage: $0 [-v] [-h] start |
stop | restart | status | startserver | startsession | stopserver |
stopsession" exit -1 ;; *) echo "Unknown parameter '$1'" echo "Usage: $0 [-v] [-h] start |
stop | restart | status | startserver | startsession | stopserver |
stopsession" exit -1
;; esac |
||
|
ShellScript |
|
>Anzahl >Parameter überprüfen |
>$# |
|
#------------------------------------------------------------------------------------------- # Input
parameter #------------------------------------------------------------------------------------------- PCID=$1 PRINTER=$2 NB=$# #------------------------------------------------------------------------------------------ # Check the
input parameters #------------------------------------------------------------------------------------------ if [ ${NB} !=
2 ] then echo "Usage: \"$ME pcno
printer\"" echo " e.g. \"$ME pc3856:0.0
pclzainet\"" exit 1 else ... fi ... |
||
|
ShellScript |
|
>Anzahl >Datensätze,
>records, >wc
|
>nb |
|
NB_REC_FILE=`cat
${DIR}/${FILE} | wc -l | sed "s/ //g"` |
||
|
ShellScript |
|
Dialogmaske starten
|
>aixterm,>term |
|
DISP=$1 PRINTER=$2 NO=$# WRK_PATH=$ZNDIR/ETB FOUR_GL=etb_disp.4ge #------------------------------------------------------------------------------------------ # display mask and start 4gl-program to select new
trade(s) of date or tnum #------------------------------------------------------------------------------------------ /usr/bin/X11/aixterm
-T "UEBERSCHRIFT" \ -d $DISP \ -fn 7x13 \ -bg Hintergrundfarbe,
z.B. yellow \ -fg Schriftfarbe, z.B
black \ -geometry
110x25+0+0 \ -e env TERM=vt100
$WRK_PATH/$FOUR_GL -d$ZNDBS -p$ZNDIR sleep 20 if [ $? != 0 ]; then echo
"The aixterm command did not work correctly." sleep 20 exit 1 fi ... oder ... if [ $# = 0 ]; then echo
"Usage: $ME <macro_name> <Display> [<printer>]" exit 1 fi if [ $# = 1 ]; then echo
"Usage: $ME <macro_name> <Display> [<printer>]" exit 1 fi if [ $# = 2 ]; then MACRO=$1
DISPLAY=`echo $2 | awk -F":" '{print $1}'` echo
"display=$DISPLAY" fi if [ $# = 3 ]; then MACRO=$1 DISPLAY=`echo
$2 | awk -F":" '{print $1}'` echo
"display=$DISPLAY" export
PRINTER=$3 fi LOG_FILE=$ZNLOG/$MACRO.log export DISPLAY=$DISPLAY:0.0 echo macro=$MACRO disp=$DISPLAY prt=$PRINTER /usr/lpp/X11/bin/aixterm
\ -display
$DISPLAY \
-geometry 30x1 \ -fg
Wheat -bg CadetBlue \ -T
"Running Macro $MACRO" \ -e
$ZNSCR/show_dots \ & aixterm_pid=$! echo aixterm_p ... |
||
|
ShellScript |
|
Ausdruck aus Shell ausführen |
>qprt |
|
PRINTER=pclzainet
oder PRINTER=dk004zai ... #---------------------------------------------------------------------------------------------------- # Check the printer queue first; start printing of
paper tickets on specified printer #---------------------------------------------------------------------------------------------------- lpstat -p$PRINTER | grep READY if [ $? != 0 ]; then
$ERROR_CHECK 81 $ME if [ $? !=
0 ]; then exit 100; fi fi echo
"Drucke Tickets fuer Gold auf $PRINTER ..." qprt
-P$PRINTER ZuDruckendeDatei echo
"done." |
||
|
ShellScript |
|
|
>grep, >egrep |
|
LMENB=`cat
${TMP_CLT}/${LMEPATT}${LMEDATE}.dat.${CURR_DTE} | egrep ${LMEDATE}'07|12' | wc -l` cat ${TMP_CLT}/${LMEFILE}.${CURR_DTE}
| egrep -v 'CALL|PUT' | \ egrep
'^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]12AA[ A-Z][ A-Z][ A-Z][0-9][0-9]*'
| \ sort +0 -42
> ${TMP_CLT}/${LMEFILE}.${CURR_DTE}.lme.fut.usd.alu.maturities cat ${FILE} |
egrep 'PR' | egrep 'D' | egrep 'RWE|EON|ENBW|VE' > ${FILE}.temp cat
${TMP_CLT}/${EEXFMRFFILE} | egrep 'PR.F1' > ${TMP_CLT}/${EEXFMRFFILE}.eex.phelix |
||
|
ShellScript |
|
Blocksize einer Datei bestimmen und prüfen |
awk |
|
#---------------------------------------------------------------------------------------------------- # Get the file size and check if it's correct #---------------------------------------------------------------------------------------------------- blksize=`ls –l $TRANS_FILE | awk '{print $5}'` correct_size=`echo $blksize | awk '{if ( (($1 % 600)
== 0) && ($1 != 600) ) {print 1} else {print 0}}'` if [ $correct_size != 1 ]; then $ERROR_CHECK 13 $ME if [ $? != 0 ]; then exit 100; fi fi |
||
|
ShellScript |
|
Bedingung für Ausgabe Dateigröße |
>ls, awk, >if |
|
ls -l | awk ' { if ( $5 > 1000000 ) print
$5,$6,$7,$8,$9,$10 } ' |
||
|
ShellScript |
|
find out if server is
'reachable' by the server
|
>ping |
|
ping -s
<host> f985757@fftusp7712:/var/mxcom/ods$ ping -s nephtys 64 bytes from FFTUSD5201.de.bnksdnerkb.com
(10.196.106.50): icmp_seq=0. time=0.728 ms 64 bytes from FFTUSD5201.de.bnksdnerkb.com
(10.196.106.50): icmp_seq=1. time=0.599 ms 64 bytes from FFTUSD5201.de.bnksdnerkb.com
(10.196.106.50): icmp_seq=2. time=0.655 ms |
||
|
ShellScript |
|
Datum aus letzten Handelstag erstellen, >srho |
>awk, >substr |
|
if [ -z "$DATUM" ]; then exec
4<$ZNTCH/zainet_last_trade_date read -u4
DATUM exec
4<&- JJ=`echo
$DATUM | awk ' { print substr($0,8,2) } '` MM=`echo
$DATUM | awk ' { print substr($0,3,3) } '` DD=`echo
$DATUM | awk ' { print substr($0,1,2) } '` DATUM=$DD$MM$JJ fi cat
eodsrho.ODS_data | awk ' { print substr ($0,134,9) }' | sort -u |
||
|
ShellScript |
|
Datei-Versionsnummer pflegen |
>awk, >cat, $? |
|
ME=`basename $0` ... PREFIX=$ME ... SAVE_DIR=$ZNSAV/ZN2BS # directory where
history files are stored ... HIST_FILE=${PREFIX} #
prefix of files in historical database TRANS_FILE=$ZNTR/${PREFIX}.transfer # name of file to be transferred (copied
from $EBC) REM_FILE="bpal.azv.zainet(+1)" # name of remote file is a Host
GDG !!!LIVE!!! EBC=$ZNTR/${PREFIX}_ebc.dat # name of ebcdic file created by zainet UNL_FILE=$ZNTR/${PREFIX}_bs.unl # name of ascii unload file
created by zainet VER_FILE=$SAVE_DIR/${PREFIX}.version # file containing the current number of
history file LOG_FILE=$ZNLOG/${PREFIX}.log # log file which is displayed by tail_term ... #---------------------------------------------------------------------------------------------------- # Write the "historical database" #---------------------------------------------------------------------------------------------------- next_version=`cat $VER_FILE | awk '{print $1+1}'` cp $UNL_FILE $SAVE_DIR/$HIST_FILE.$next_version RC=$? if [ $RC != 0 ]; then
$ERROR_CHECK 20 $ME if [ $? !=
0 ]; then exit 100; fi fi echo $next_version > $VER_FILE #---------------------------------------------------------------------------------------------------- # Check if the version number was written correctly #---------------------------------------------------------------------------------------------------- old_version=`cat $VER_FILE | awk '{print $1}'` if [ $old_version != $next_version ]; then
$ERROR_CHECK 21 $ME if [ $? !=
0 ]; then exit 100; fi fi |
||
|
ShellScript |
|
Warteschleife; wait_for |
>sleep, >while |
|
ARGC=$# ERR=$1 WAIT_FOR=$2 MYSELF=$3 ... SLEEP=100 MAX_LOOPS=10 ... if [ "$ARGC" -ne "3" ] then echo
"usage \"wait_for <error_number> <wait_finish>
<calling_pgm>\"" exit 100 fi no_loops=0 must_wait=0 while [ -r $ZNTCH/$WAIT_FOR.running ]; do
must_wait=1
no_loops=`expr $no_loops + 1` datum=`date
+"%d%b%y, %H:%M"`: echo
"$MYSELF $no_loops: Waiting for $WAIT_FOR to finish (sleeping for $SLEEP
seconds ...)" echo
"$MYSELF $no_loops: Waiting for $WAIT_FOR to finish at $datum" >>$ZNLOG/wait_for.log sleep
$SLEEP if [
$no_loops = $MAX_LOOPS ]; then echo
"$MYSELF $ME: Number of maximal sleep loops ($MAX_LOOPS)
exceeded.Exiting." echo
"$MYSELF $ME: Number of maximal sleep loops ($MAX_LOOPS)
exceeded.Exiting at $datum ."
>>$ZNLOG/wait_for.log
$ERROR_CHECK $ERR "$MYSELF" rc=$? if [ $rc != 0 ]; then exit $rc; fi break fi done echo "\n$MYSELF must not $WAIT_FOR to
finish at $datum" echo "$MYSELF must not $WAIT_FOR to finish at $datum" >>$ZNLOG/wait_for.log |
||
|
ShellScript |
|
Warteschleife mit Ausgabe der vergangen Zeit per Pünktchen |
>sleep, >print |
25.08.03 |
# # procedure sleepy # sleepy() { COUNT=$1 while [
$COUNT -gt 0 ] ; do print -n
"." sleep 1 let
COUNT=COUNT-1 done echo "." } |
||
|
ShellScript |
|
Log-Eintrag ins 'ALL.log' (Zai*Net) |
>>, >qprt,
>bsh |
|
ZNSCRIPT=$1 zndate=`date +"%d%b%y, %H:%M"` Machine=`hostname` echo "\n*++++++++++++ Starting script
'$ZNSCRIPT' on $zndate on Machine: $Machine\n" echo ": \"\\n*++++++++++++ Starting script
'$ZNSCRIPT' on $zndate on machine: $Machine" >>
$ZNDIR/LOG/ALL.log" | qprt –Pbsh
# wir ueber quasi-Druckerqueue eingestellt, wg. Organisation gleichzeitiger Eintraege sleep 1 |
||
|
ShellScript |
|
Prozeß stbnken (killen) |
>kill |
|
man kill: "Sends a signal to running processes.
" JOBS=`ps –ef | grep $JOB | grep -v grep | awk
'{print $2}'` for pid in $JOBS; do echo -n
"Killing $pid ..." kill $pid echo "
Done." done by the way: alle Parameter von kill anzeigen oftzai05:admin/WAN 198> kill -l 1) HUP 14) ALRM 27)
MSG 40) bad trap 53) bad trap 2) INT 15) TERM 28)
WINCH 41) bad trap 54) bad trap 3) QUIT 16) URG 29)
PWR 42)
bad trap 55) bad trap 4) ILL 17) STOP 30)
USR1 43) bad trap 56) bad trap 5) TRAP 18) TSTP
31) USR2 44)
bad trap 57) bad trap 6) ABRT 19) CONT 32)
PROF 45) bad trap 58) bad trap 7) EMT 20)
CHLD 33) DANGER 46) bad trap 59) bad trap 8) FPE 21)
TTIN 34) VTALRM 47) bad trap 60) GRANT 9) KILL 22) TTOU 35)
MIGRATE 48) bad trap 61) RETRACT 10) BUS 23) IO
36) PRE 49)
bad trap 62) SOUND 11) SEGV 24)
XCPU 37) bad trap 50) bad trap 63) SAK 12) SYS 25) XFSZ 38)
bad trap 51) bad trap 13) PIPE 26)
bad trap 39) bad trap 52) bad trap |
||
|
ShellScript |
|
for-Schleife |
>for >do |
|
for
trade in ${TRD_LST}; do
trdnoext=`echo $trade | cut -d'.' -f1`
unique=`date +%y%m%d-'%H'%M%S`-$$ . . . done ============================================================================================ for dcode in B W M Y do for
cnt in 1 2 3 4 5 6 7 8 9 10 11 do
if [ "$dcode" = "W" -a $cnt -gt 3 ]; then
break
fi
if [ "$dcode" = "Y" -a $cnt -gt 10 ]; then/lösch
break
fi
if [ "$dcode" = "B" ]; then
if [ $cnt -gt 6 ]; then
break
fi
if [ $cnt -eq 2 ]; then
cnt=""
dcode="SPOT"
fi
fi
echo "EUROCONV|$TAG|F|$CCY|FX|$cnt$dcode|$FAK|"
echo "EUROCONV|$TAG|F|$CCY|FX|$cnt$dcode|$FAK|" >&3 done done |
||
|
ShellScript |
|
löschen mit find |
>find, >mtime |
02.03.01 |
Dateien
des Verzeichnisses, die dem Muster entsprechen und älter als fünf Tage sind,
löschen! find $LOG_DIR –name
'*.[0-9][0-9][0-9][0-9][0-9][0-9]' -mtime +5 -exec rm {} \; find $DATA_DIR –name '*.[0-9][0-9][0-9][0-9][0-9][0-9]*.lis'
-mtime +5 -exec rm {} \; find $DATA_DIR –name
'*.[0-9][0-9][0-9][0-9][0-9][0-9]*.dat' -mtime +5 -exec rm {} \; find $DATA_DIR/sav -name
'*.[0-9][0-9][0-9][0-9][0-9][0-9]' -mtime +5 -exec rm {} \; Problem:
Parameterliste fuer zu lang fuer "rm –f *idx *dat"; Loesung: find $DIRECTORY -name "*.idx" -exec rm -f
{} \; find $DIRECTORY -name "*.dat" -exec rm -f
{} \; Aufräumen
im Unload-Verzecinis: find . -name "sql_unl.27*" -exec ls -lrt
{} \; (zeigt an) find . -name "sql_unl.27*" -exec rm {}
\; (löscht) find . -name "*log" -mtime +7 -exec {} \; (in
/opt/mxcom/today/data) oder (online_end) echo "Deleting old data in $ZNSAV." cd $ZNSAV find . | -ctime -7 -exec rm -r {} \; echo "Deleting all core files created during
the day." find $ZNDIR -name core -exec rm {} \; find $ZNDIR -name mu.log -exec rm {} \; find $ZNDIR/LOG | -ctime -60 -exec rm {} \; Suchen
in Unterverzeichnissen: find ./
-name "*.*" | xargs grep "foo" |
||
|
ShellScript |
|
Umgebungsvariable setzen |
>path |
02.03.01 |
#
SET INGRES ENVIRONMENT PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:/local/ingres/bin:/local/ingres/utility:. export
PATH |
||
|
ShellScript |
|
Datei suchen, >oder, >und, >or, >and |
>while, >||,
>&& |
02.03.01 |
BASE_DIR=/local/ingres_apps/zainet # Base directory DATA_DIR=$BASE_DIR/data # DATEN-DIRECTORY LOG_DIR=$BASE_DIR/log # Log-Directory TAG=`date +%y%m%d` DB=ncmdb ZN_FILE=position_zn.rpt CURR_FILE=curr_pos.txt LOG_FILE=$LOG_DIR/abgl_log.$TAG ERROR_FILE=$LOG_DIR/abgl_err.$TAG DELAY=120 while [[ ! -f $DATA_DIR/$ZN_FILE || ! -f
$DATA_DIR/$CURR_FILE ]] ; do print "Die Dateien sind noch
nicht vorhanden: `$TIMESTAMP`" >>$LOG_FILE sleep $DELAY done oder if [[ "${PRCMF}" = "metal" ]]
&& [[ "${SPOT}" = "future" || "${SPOT}"
= "nonusdfuture" ]]; then |
||
|
ShellScript |
|
Dateigröße bestimmen und vergleichen |
>ls –lisa, >awk |
02.03.01 |
FILESIZE=`ls -lisa $DATA_DIR/$ZN_FILE | awk '{printf
$7}'` FILESIZE=${FILESIZE}+`ls -lisa $DATA_DIR/$CURR_FILE
| awk '{printf $7}'` sleep $DELAY FILESIZE_NEU=`ls -lisa $DATA_DIR/$ZN_FILE | awk
'{printf $7}'` FILESIZE_NEU=${FILESIZE_NEU}+`ls -lisa
$DATA_DIR/$CURR_FILE | awk '{print $7}'` while [[
$FILESIZE != $FILESIZE_NEU ]]; do print "Die Dateien wachsen noch:
`$TIMESTAMP` " >> $LOG_FILE FILESIZE=FILESIZE_NEU sleep
$DELAY
FILESIZE_NEU=`ls -lisa $DATA_DIR/$ZN_FILE | awk '{printf $7}'`
FILESIZE_NEU=${FILESIZE_NEU}+ \
`ls -lisa $DATA_DIR/$CURR_FILE | awk '{printf $7}'` done |
||
|
ShellScript |
|
Zeilen einer Datei sortieren und zusammenfassen |
>sort, >uniq |
02.03.01 |
cat $DATA_DIR/$ZN_FILE | sort | uniq >
$DATA_DIR/$ZN_FILE.$TAG.dat |
||
Größe von Dateien eines Verzeichnisses anschauen |
>find,>sort,>$$ |
|
find
$ZNDIR/admin/WAN -ls 2>/dev/null | awk ' { print $7, "\t", $11
}' | sort -n > abc.$$ vi
abc.$$ # "$$" ist die
Prozeß-ID des Parent (wahrscheinlich, um eindeutige Datei zu erzeugen) \rm
abc.$$ #"\" verhindert den
Zugriff auf Aliase (die evt. eine Bestätigung abfragen) |
||
|
ShellScript |
|
FTP |
>ftp |
|
FTP=/bin/ftp (oder wo auch immer) FTP_DDF_SERVER=321.321.21.1 FTP_DDF_USER=buero FTP_DDF_PASSWD="passwd" FTP_DDF_DIR=$DDF_DIR show_log "FTP-Transfer fuer Semaphorendateien
gestartet" $FTP -n
$FTP_DDF_SERVER <<EOFTP 1>/dev/null 2>&1 user $FTP_DDF_USER
$FTP_DDF_PASSWD ascii get
$FTP_DDF_SEMAPHORE_N $DDF_SEMAPHORE_N get
$FTP_DDF_SEMAPHORE_V1 $DF_SEMAPHORE_V1 get
$FTP_DDF_SEMAPHORE_V2
$DDF_SEMAPHORE_V2 quit EOFTP show_log
"FTP-Transfer beendet" |
||
|
ShellScript |
|
>wget, >ftp, >eex, >proxy |
>wget |
|
FTP_PRX="10.199.212.129" #
ftp proxy adbnkss FTP_PRX="10.199.212.131" #
ftp proxy adbnkss FTP_PRT="8080" # ftp proxy port # eex ftp #
Mathias.Ponnwitz@eex.com, +49(0)341/2156-214, www.eex.com #EEXHOST="ftp.eex.com" #
eex ftp ip adbnkss (EEXHOST couldn't be resolved) EEXIP="193.138.68.85" #
eex ftp ip adbnkss (EEXHOST couldn't be resolved) EEXUSER="3409aas" #
ftp user / account / profile EEXPW="qcrgeh" #
ftp p...word EEXFMRFDIR="market_results/power/derivatives_market/futures" EEXSARFDIR="market_results/power/spot_market/auction_trading" /bin/sh -c
"LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/sfw/lib:/usr/openwin/lib;\ ftp_proxy=${FTP_PRX}:${FTP_PRT};export
LD_LIBRARY_PATH;export ftp_proxy;\ /usr/local/bin/wget
ftp://${EEXUSER}:${EEXPW}@${EEXIP}/${EEXFMRFDIR}/file01.csv" |
||
|
ShellScript |
|
Letzte Handelstagdatum ausgeben |
>printf |
|
exec 4<$ZNTCH/zainet_last_trade_date read -u4 DATUM exec 4<&- DATUM=`echo $DATUM | awk '{printf
"%s%s",substr($1,1,5),substr($1,8,2)}'` |
||
|
AWK |
|
Logfiles
leeren
|
>cp,/>dev/>null |
|
cp /dev/null $ZNLOG/start_datafeed.log cp /dev/null $ZNLOG/shredder_long.log cp /dev/null $ZNDIR/dbs/$ZNDBS/mac.log |
||
|
ShellScript |
|
Betragsbildung
|
ABS |
20.08.01 |
function ABS { WERT=$1 if [ $WERT
-le 0 ] then WERT=`echo $WERT | awk ' { print $1 *
-1 }' ` fi } |
||
|
ShellScript |
|
Alte
Tabellen finden
|
>find, >expr |
02.07.2001 |
name=`find
$ZNDIR/dbs/dbs.dbs/z[a-g]*.dat -mtime
+60 -ls | awk '{print $11 }' ` for i in $name; do a=`basename
$i` v=`expr $a : '\([^.]*\).*'` # schneidet alles nach dem ersten Punkt
"." ab b=`$ZNSCR/exec_sql_stmt
$ZNDIR/dbs/dbs "select tabname, dirpath from systables where
dirpath=\"$v\""` c=`expr $b : '\([^|]*\).*'` # schneidet alles nach dem ersten pipe
"|" ab echo $b >>t_f_60.log echo $c >>t_60.log echo $c >>t_60_size.log done |
||
>for |
ShellScript
|
|
business calculator, Rechnen, Differenz,
Addition, Multiplikation
|
>bc |
01.02.02
|
Ausführung
in einer Shell mit Zuordnung an lokale Variable: ONPRC=` echo "$SPPRC -
$W1PRC" | bc `
oder ERG=`echo
"scale=8;(($SPPRC-$W1PRC)/($W1VAL-$SPVAL))*$SPVAL" | bc ` |
||
Berechnung |
ShellScript |
|
Steuerungszeichen
eingeben
|
^ |
|
im
UNIX-Umfeld durch: Strg V Strg <Zeichen> |
||
|
ShellScript |
|
Symbolischen
Link anlegen
|
>link |
|
ln -s
Quelle Ziel |
||
|
ShellScript |
|
Endlosschleife
in Shell als einzelne Zeile angegeben
|
>while, >loop |
|
while [ 1 = 1 ]; do^Jecho "test"^Jsleep
1^Jdone while [ 1 = 1 ]; do^Jls -lrt *.running^Jsleep
5^Jdone (^J durch
Strg V Strg J !!!) |
||
>Schleife,
>endlos, >shell |
ShellScript |
|
condition,
loop, max, sleep
|
>while, >loop |
2007 |
LOOP_MAX=10 LOOP_SLP=300 # loop with condition, e.g. transferred file as of
today:w LOOP_CNT=1 while [ ${LOOP_CNT} -le ${LOOP_MAX} ]; do # check
transfered file for date (to be a current one) FILEDATE=`echo
${FILENAME} | \ sed
"s/^file_\([0-2][0-9][0-9][0-9][0-9][0-9][0-3][0-9]\)\.csv/\1/"` if [ ${FILEDATE}
-ne ${TODY_BODTE} ]; then echo "Condition not fulfilled - try
again($LOOP_CNT)!"
LOOP_CNT=`expr $LOOP_CNT + 1` # check if
maximum of loops reached if [
${LOOP_CNT} -gt ${LOOP_MAX} ]; then MAILTEXT="Condition not fulfilled! \ \n\nTried
every $LOOP_SLP sec for $LOOP_MAX times now - will terminate!" echo
$MAILTEXT | mailx -s "upload : Alert . . ." $EMAILADBNKSS exit 2 fi sleep
${LOOP_SLP} else echo "Condition fulfilled - will go
ahead . . ." break fi done |
||
>Schleife,
>Shell |
ShellScript |
|
multiple loop, nested loop, Jan, Feb, >month, >Monat, >ersetzen, >sed
|
>for, >read |
|
# Liste,
über die "äußere Schleife" läuft (für jedes unterschiedlich
vorkommendes Feld #4) DTELST=`cat ${INP_FILE} | awk -F',' ' {
print $4 } ' | sort -u` echo "Processing for `echo $DTELST | wc -w |
sed 's/ //g'` records" for prcdate
in ${DTELST}; do # Es wird die "innere Schleife" fuer
jedes Element der "äußeren Schleife" durchlaufen MIDCNT=0 cat ${INP_FILE}
| grep ${prcdate} | while read record; do
MIDCNT=`echo "${MIDCNT} + 1" | bc` # read
data
HighLowFlag=`echo "${record}"
| cut -d"${DELIM}" -f3` if [
${HighLowFlag} -eq 1 ]; then
LowPrc=`echo "${record}"
| cut -d"${DELIM}" -f5` elif [
${HighLowFlag} -eq 2 ]; then
HighPrc=`echo "${record}"
| cut -d"${DELIM}" -f5` else
display_log "ERROR: Can't determine high/low flag
(${HighLowFlag}) - please check!"
MAILTEXT="Can't determine high/low flag (${HighLowFlag}) - please
check!" echo
$MAILTEXT | mailx -s "Subjekte Ueberschrift" fi
Date=`echo "${record}"
| cut -d"${DELIM}" -f4 | \ sed
"s/^\([0-9][0-9]\)-\([A-Z][a-z][a-z]\)-\([0-9][0-9][0-9][0-9]\)/\3\2\1/"
\ | sed
"s/JAN/01/;s/FEB/02/;s/MAR/03/;s/APR/04/;s/MAY/05/;s/JUN/06/; \ s/JUL/07/;s/AUG/08/;s/SEP/09/;s/OCT/10/;s/NOV/11/;s/DEC/12/;
\
s/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/; \ s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/"` done if [ -n
"${LowPrc}" -a -n "${HighPrc}" ]; then SettlPrc=`echo ${LowPrc} ${HighPrc} | awk '
{ print ( $1 + $2 ) / 2 } '` elif [
-n "${LowPrc}" -a -z "${HighPrc}" ]; then SettlPrc=${LowPrc} display_log "high price is missing -
set closing price to low price" elif [ -z "${LowPrc}" -a -n
"${HighPrc}" ]; then SettlPrc=${HighPrc} display_log "low price is missing -
set closing price to high price" else display_log "ERROR: Can't find high/low
flag (${HighLowFlag}) - please check!"
MAILTEXT="Can't find high/low flag (${HighLowFlag}) - please
check!" echo
$MAILTEXT | mailx -s "mxcom upload '$PUD $ENVIR': Argus nat gas spot
indix price!" fi # opening
tags
XMLbody[01]="<cmip:index xc:value=\"${Label}\">"
XMLbody[02]="<cmip:quotation
xc:value=\"${SpotUnitDflt}\">"
XMLbody[03]="<cmip:column xc:type=\"Fields\"
xc:value=\"CLOSE\">" # data
XMLbody[04]="<mp:HisValue
xc:type=\"Field\">[startDate=\"${Dte}\"][endDate=\"${Dte}\"]${Prc}</mp:HisValue>" # closing
tags
XMLbody[05]="</cmip:column>"
XMLbody[06]="</cmip:quotation>"
XMLbody[07]="</cmip:index>" # build xml
file body (up) for cnt in 1
2 3 4; do
createTabs `expr $cnt + 6` echo
"${tabsp}"${XMLbody[$cnt]} >> ${TMP_CLT}/${OUTPUT} done # build xml
file body (down) for cnt in 5
6 7; do
createTabs `expr 15 - $cnt` echo
"${tabsp}"${XMLbody[$cnt]} >> ${TMP_CLT}/${OUTPUT} done done |
||
>Schleife,
>dbnkelt |
ShellScript |
|
Mittels
Array und for-Schleife eine >xml Struktur erstellen
|
>for, >array |
|
tabsp="
" [ -n "${TMP_CLT}/${OUTPUT}" -a -s
${TMP_CLT}/${OUTPUT} ] && rm ${TMP_CLT}/${OUTPUT} XMLheader[01]="<xc:XmlCache
xmlns:xc=\"XmlCache\" xc:action=\"Update\">" XMLheader[02]="<xc:XmlCacheArea
xc:value=\"MarketParameters\">" XMLheader[03]="<mp:nickName
xc:value=\"PROVIDER1.PAGECOM\"
xmlns:mp=\"mx.MarketParameters\">" XMLheader[04]="<mp:date
xc:value=\"TODAY\">" XMLheader[05]="<fg:fixing
xmlns:fg=\"mx.MarketParameters.Fixing\">" XMLheader[06]="<fgci:CompoundIndices
xmlns:fgci=\"mx.MarkParam.Fixing.CompoundIndices\">" XMLheader[07]="<fgci:archivingSeries
xc:value=\"LME\">" for cnt in 1 2 3
4 5 6 7; do createTabs
$cnt echo
"${tabsp}"${XMLheader[$cnt]}
>> ${TMP_CLT}/${OUTPUT} done |
||
|
ShellScript |
|
>mail,
>send, >text, >mailx
|
>mail |
2007 |
MAILADBNKSS="WenEsInteressiert@gmx.com" MAILTEXT="Da
stimmt was nicht \ \nBitte prüfen\n \ \nUnd zwar so und so \ \n\nNix ausgeführt - will
terminate!" echo $MAILTEXT | mailx -s "Subject Ueberschrift
Text" $MAILADBNKSS |
||
|
ShellScript |
|
Ports
überprüfen
|
>netstat |
|
netstat -an
| grep <Portnummer> Sucht nach Verbindungen
zum Port (listener). Dies können
auch durch einen inzwischen gekillten Prozess
geöffnete Dateien sein. |
||
|
ShellScript |
|
Freier
Plattenspeicherplatz gemounteter Speichermedien, disc free
|
>df |
09.09.2002 |
df Übersicht aller gemounteten Platten df -k Übersicht in KiloByte df -k . Aktuelle
Plattensystem in KB |
||
|
ShellScript |
|
Plattenspeicher-Belegung,
Belegte Datenblöcke, disk usage
|
>du |
09.09.2002 |
du Übersicht des aktuellen Verzeichnisses du -k Übersicht in KiloByte du –sk * Gesamtsummen
des belegten Filesystem-Speichers df -k or df
-k . (disk free in kilobyte) du -ks or du -ks * (sum of disk used in
kilobyte) |
||
|
ShellScript
|
|
Prozess-Status
|
>ps |
08.01.2004
|
Ohne
Parameter ps PID
TTY TIME CMD 50880 pts/4
0:00 -ksh 58512 pts/4
0:00 -ksh 68480 pts/4
0:00 clnproc 78212 pts/4
0:01 ./olkview ofapmxg04 9003 /nomail 92532 pts/4
0:00 ps Alle Prozesse als Liste ps -efa b78wan 57748
60112 0 Jan 05
pts/3 0:00 -ksh murex
57966 88924 0 08:31:06 -
3:05 ./mx /MXJ_LOG: /MXJ_CLIENT_HOST:pc6884
/MXJ_CLIENT_IPADDR:138.75.68.84 /IPHOST:ofapmxg04: b78wan 58512
55352 0 Jan 05
pts/4 0:00 -ksh murex 59478
32570 0 murex 59796
65968 0 b78wan 60112
6578 0 Jan 05
- 0:06 /usr/bin/X11/aixterm . . . ps v PID TTY
STAT TIME PGIN SIZE
RSS LIM TSIZ
TRS %CPU %MEM COMMAND 20064 pts/0 A
0:00 55 584
484 1048575 188 224
0.0 0.0 -ksh 21692 pts/1 A
0:00 0 196
148 1048575 3 4
0.0 0.0 tee -al 50880 pts/4 A
0:00 106 612
480 1048575 188 224
0.0 0.0 -ksh 51112 pts/1 A
55856 pts/3 A
0:01 90 772
568 1048575 188 224
0.0 0.0 -ksh 58512 pts/4 A
0:00 0 736
240 1048575 188 224
0.0 0.0 -ksh 61946 pts/5 A
0:00 155 620
496 1048575 188
224 0.0 0.0 -ksh 64946 pts/7 A
0:00 15 600
240 1048575 188 224
0.0 0.0 -ksh 68480 pts/4 A
0:00 1 92
92 1048575 2 4
0.0 0.0 clnproc 74688 pts/1 A
0:00 31 596
800 1048575 188 224
0.0 0.0 -ksh 78212 pts/4 A
0:01 344 2996
4580 1048575 2826 1584
0.0 0.0 ./olkvie 81042 pts/18
A 0:00 9
604 600 1048575 188
224 0.0 0.0 -ksh 85256 pts/8 A
0:00 0 580
788 1048575 188 224
0.0 0.0 -ksh 93486 pts/4 A
0:00 0 640
708 1048575 52 68
0.0 0.0 ps v 101678 pts/4 A
0:00 47 592
816 1048575 774 224
0.0 0.0 ./mxwexp Wie ps v
nur für übergebene PID [ofapmxg04] { log } > ps v 51112 PID TTY STAT TIME PGIN
SIZE RSS LIM
TSIZ TRS %CPU %MEM COMMAND 51112 pts/1 A 1:19
255 27600 26116 1048575
23 32 0.2
0.0 java -Xm -------------------------------------------------------------------------------------------- Eintrag als
'alias' in ".profile' (kann dann direkt aus Unix-Shell aufgerufen
werden) psg='ps -ef
| grep -i $@' -------------------------------------------------------------------------------------------- if [ -s ${PID_DIR}/${ME}.${DBUS_ADAPT}.pid ]; then
PID2KILL=`cat ${PID_DIR}/${ME}.${DBUS_ADAPT}.pid` if [ `ps -f | grep ${PID2KILL} | wc -l` -gt
0 ]; then echo
"Script '${ME}' adapt '${DBUS_ADAPT}' pid '${PID2KILL}' already started
- abort!" exit 1 else
display_log "WARNING: For pid '${PID2KILL}' no process found -
please check!" fi fi |
||
|
ShellScript |
|
process status with ‘
|
>/usr/>ucb/>ps |
23.02.2006
|
/usr/ucb/ps -axw /usr/ucb/ps -axww | grep '\./mx' | grep CLIENT -a . . . processes of other users -x . . . processes without terminal -w . . . wide listing -------------------------------------- -u . . .
user -l . . .
long listing to find out related user: DOSE: nbtstat –a frax4fo46o024w1 |
||
|
ShellScript |
|
process
arguments / parameter
|
>pargs |
07.11.2007 |
ff1p3746app:/usr/local/tools/mur/bin$ sudo -u
curplus pargs 5098 5098:
/opt/DKBjava/1_5_0_05/bin/java -Dadaptor=KondorToMurexFXSpot
-Denvironment=MURP argv[0]: /opt/DKBjava/1_5_0_05/bin/java argv[1]: -Dadaptor=KondorToMurexFXSpot argv[2]: -Denvironment=MURPROD argv[3]: -Dproduction=true argv[4]: -Dlog4j.configDebug=false argv[5]: -cp argv[6]:
/opt/curplus/dealbusFW/config:/opt/curplus/dealbusFW/lib/dealbusFW.jar: . . . argv[7]:
com.drkw.dealbusFW.adaptor.RunDealbusAdaptor argv[8]: KondorToMurexFXSpot |
||
|
ShellScript |
|
Volume
Group Einteilung
|
>lsvg |
14.10.2002 |
lsvg Übersicht der zugehörigen
volume groups ofszai04:/local/zainet/bnk/fx/v4 497>
lsvg rootvg zaivgbck zaivg2 zaivg1 lsvg zaivg1 ofszai04:/local/zainet/bnk/fx/v4 499>
lsvg zaivgbck VOLUME GROUP: zaivgbck VG IDENTIFIER: 000884645e2987aa VG STATE: active PP SIZE: 16 megabyte(s) VG PERMISSION: read/write TOTAL PPs: 536 (8576 megabytes) MAX LVs: 256 FREE PPs: 536 (8576 megabytes) LVs: 0 USED PPs: 0 (0 megabytes) OPEN LVs: 0 QUORUM: 1 TOTAL PVs: 2 VG DESCRIPTORS: 2 STALE PVs: 0 STALE PPs 0 ACTIVE
PVs: 1 AUTO ON: yes Bedeutungen (Auszug): Kann immer in 16MB(PP SIZE)-Teilen aufgeteilt werden; momentan verfügbarer Speicherplatz 536x16 MB = 8,5 GB (TOTAL PPs); davon verfügbarer Speicher 8,5 GB (FREE PPs); ggw. genutzter Speicherplatz 0 (USED PPs) |
||
|
ShellScript |
|
makefile
(Default-Beschreibungsdatei für make-Hilfsprogramm) |
>make |
25.06.2002 |
# Zuerst
werden die Makrodefinition vorgenommen: "Makroname = Zeichenfolge"
(quasi lokale Variablen) # Dann
werden die Abhängigkeitszeilen definiert: "Ziele: Voraussetzung"
(mit auszuführendem Befehl) MXG2000 = /backup/murex/mxg2000/bin # Pfad CC = gcc #
GNU C-Compiler RM = rm -f #
Remove CP = cp #
Copy CHMOD = chmod #
Change Mode CHOWN =
chown #
Change Owner CFLAGS = -O #
Compilierungsflag: Optimierung INCLUDE =
-I. #
Verzeichnisangabe für Includedateien LDFLAGS =
-L. -l_eolk #
Verzeichnisangabe Bibliotheken (lib_eolk.a) # Erstellen
der ausführabren Datei (Executable) aus der Objektdatei olk_bond:
olk_bond.o $(CC)
$(CFLAGS) $(LDFLAGS) -o olk_bond olk_bond.o # Erstellen
der Objektdatei aus der C-Quelldatei olk_bond.o:
olk_bond.c $(CC)
$(CFLAGS) $(INCLUDE) -c olk_bond.c # Löschen
der zuvor erstellten Objektdateien clean: $(RM) *.o olk_bond # Anbringen
der Ausführungsdatei und Rechtevergabe install:
olk_bond $(CP)
olk_bond $(MXG2000)/ $(CHMOD) 755 $(MXG2000)/olk_bond |
||
gcc
(GNU C-Compiler) |
Applikation |
MxG2000 |
+----------------------------------------------------------------------------------------------------
>ldd, >LD_LIBRARY_PATH
+----------------------------------------------------------------------------------------------------
ldd zeigt Shared Libraries, die von den auf der Kommandozeile angegebenen Dateien benötigt werden.
Datei kann entweder ein Programm oder eine weitere
Library-Datei sein.
ff1p3746app:/usr/local/tools/mur/bin$
ldd writeToOLK_C
/usr/local/tools/olk/lib/libeolk.so
libstdc++.so.6 => (file not found)
libm.so.1 => /lib/libm.so.1
libgcc_s.so.1 => (file not found)
libc.so.1 => /lib/libc.so.1
libnsl.so.1 => /lib/libnsl.so.1
libsocket.so.1 =>
/lib/libsocket.so.1
libmp.so.2 => /lib/libmp.so.2
libmd5.so.1 => /lib/libmd5.so.1
libscf.so.1 => /lib/libscf.so.1
libdoor.so.1 => /lib/libdoor.so.1
libuutil.so.1 => /lib/libuutil.so.1
libm.so.2 => /lib/libm.so.2
/platform/SUNW,Sun-Fire-V890/lib/libc_psr.so.1
/platform/SUNW,Sun-Fire-V890/lib/libmd5_psr.so.1
FFTUSD7730:/usr/ucb$ ldd ps
libc.so.1 => /usr/lib/libc.so.1
libdl.so.1 => /usr/lib/libdl.so.1
/usr/platform/SUNW,Sun-Fire-V440/lib/libc_psr.so.1
FFTUSD7730:/usr/bin$ ldd ldd
libelf.so.1
=> /usr/bin/../lib/libelf.so.1
libdl.so.1
=> /usr/bin/../lib/libdl.so.1
libc.so.1
=> /usr/bin/../lib/libc.so.1
/usr/platform/SUNW,Sun-Fire-V440/lib/libc_psr.so.1
+----------------------------------------------------------------------------------------------------
Finden von Shared libraries: Anwendungen können Shared Libraries auf mehrere
Arten finden:
+----------------------------------------------------------------------------------------------------
Pfad
wird per Umgebungsvariable bekannt gemacht: $LD_LIBRARY_PATH
Vorteil:
Shared Libraries koennen verschoben und Pfad angepasst werden (keine
root-Rechte nötig)
Nachteil: Alle Benutzer der Anwendungen muessen die Variable Warten. (FHR:
"en ...")
Systemweites
Mapping von Shared Libs zu Position: Es existiert eine Datei die sagt in
welchem Verzeichnis welche Shared Lib zu finden ist. Linux: /etc/ld.so.cache,
aktualisieren mit ldconfig(8).
Vorteil:
Benutzer muessen keinen Pfad pflegen, Shared Libraries koennen verschoben
werden.
Nachteil: Muss nach jedem verschieben, installieren und deinstallieren von
Shared Libs ausgefuehrt werden. Benoetigt root-Rechte!
Pfad
ist im Binary eincompiliert, geht beim gcc mit "-Wl,-R/pfad". In
ELF-Spezifikation vorgesehen.
Vorteil:
Muss nur einmal beim Linken angegeben werden. Braucht keine root-Rechte.
Nachteil: Pfad der Shared Libraries muss zum Link-Zeitpunkt der Anwendung
bekannt sein.
+----------------------------------------------------------------------------------------------------
02.11.2007
Archiv
erstellen, ansehen, auspacken
|
>gzip,>zip,>tar, |
7/02 |
Archiv
erstellen (create) tar –cf
<Archiv>.tar <Dateiliste> tar
-cf tst05.tar ddf.neugeschaefte.dat.ok.041022.0907
ddf.neugeschaefte.dat.ok.041022.0807 Archiv
ergänzen (update) tar –uf
<Archiv>.tar <Dateiliste> tar
-uf tst05.tar ddf.veraenderungen1.dat.ok.041022.0806 =>
Dateiliste archivieren (ls > bla; vi bla; erste Zeile tar –cf;,restl.
Zeilen tar –uf; bla ausf.) Archiv
erstellen und komprimieren tar -cf -
<Dateiliste> | gzip > <Archivname>.tgz (tar gnu zip) Komprimiertes
Archiv ansehen cat
<Archivname>.tgz | gzip -d | tar -tvf - | more Archiv
demonprimieren und auspacken cat
<Archivname>.tgz | gzip -d | tar -xf - Beschreibung >gzip: Optionen: -c beläßt die zu (de)komprimierende Datei unverändert und
leitet das Ergebnis auf die Standardausgabe (Bildschirm) um. Von dort kann es mit > in eine beliebige Datei
umgeleitet werden. -d dekomprimiert die angegebenen Datei (siehe gunzip). -r komprimiert auch Dateien in allen Unterverzeichnissen. -n steuert die Geschwindigkeit und Qualität der Kompression.
-1 entspricht --fast und bewirkt eine zeiten, aber kleinere Dateien (default =
6) Bsp: gzip *.tex komprimiert
alle *.tex-Dateien des aktuellen Verzeichnisses. Das Ergebnis sind lauter
*.tex.gz-Dateien. gzip -c datei > backup.gz komprimiert
datei, beläßt diese Datei aber unverändert und schreibt das Ergebnis in
backup.gz Die
Steuerung von tar erfolgt in zwei Stufen: Zum einen
muß eine Aktion angegeben werden, die 'tar'
ausführen soll, zum anderen kann diese Aktion durch eine oder mehrere
Optionen gesteuert werden. Es muß genau eine Aktion (nicht mehr und nicht
weniger) vor allen anderen Optionen angegeben werden. Aktionen: -c erzeugt ein neues Archiv, d.h. ein eventuell vorhandenes
Archiv wird überschrieben. -d vergleicht die Dateien des Archivs mit den Dateien des
aktuellen Verzeichnisses und stellt eventuelle Unterschiede fest. -r erweitert das Archiv um zusätzliche Dateien. --delete löscht Dateien aus dem Archiv. -t zeigt das Inhaltsverzeichnis des Archivs an. -u erweitert das Archiv um neue oder geänderte Dateien. Die
Option kann nicht für komprimierte Archive verwendet werden. Vorsicht: Das
Archiv wird immer größer, weil bereits vorhandene Dateien nicht überschrieben
werden. Die neuen Dateien werden einfach angehängt. -x extrahiert die angegebenen Dateien aus dem Archiv und
kopiert sie in das aktuelle Verzeichnis. Die Dateien werden dabei nicht aus
dem Archiv gelöscht. Optionen: -C <verzeichnis> extrahiert die Dateien in das
angegebene Verzeichnis (statt ins aktuelle). -f <datei> verwendet die angegebene Datei als Archiv
(tar greift deswegen standardmäßig auf den installierten Streamer (zumeist
/dev/tape oder /dev/rmt0) zu). -N <datum> archiviert nur Dateien, die aktueller als
das angegebene Datum sind. -T <datei> archiviert bzw. extrahiert die in der Datei
angegebenen Dateinamen. -v zeigt während der Arbeit alle Dateinamen am Bildschirm
an. Wenn -v in Kombination mit dem Kommando t verwendet wird, werden
zusätzliche Informationen zu den Dateien angezeigt (Dateigröße etc.). Wenn
die Option zweimal angegeben wird, werden die Informationen noch
ausführlicher. -W überprüft nach dem Schreiben die Korrektheit der gerade
archivierten Dateien. Kann nicht für komprimierte Archive verwendet werden. -z komprimiert bzw. dekomprimiert das gesamte Archiv durch
gzip. Für das Anlegen von *.tgz-Dateien ist diese Option sehr praktisch.
!Nicht für Streamer! Anmerkung: Mit tar
kann man ebenfalls ganze Dateibäume von einer Partition auf eine andere übertragen.
Zu 'tar' gibt es eine komfortable
X-Oberfläche (xtar). Bsp: tar -czf backup_projekt.tgz
text/projekt archiviert
alle Dateien aus dem Verzeichnis text/projekt inclusiv aller Dateien aller
Unterverzeiche in der komprimierten Datei backup_projekt.tgz. tar -tzf backup.tgz zeigt alle
Dateien des Archivs an. tar -xzf backup.tgz extrahiert
das Archiv in das aktuelle Verzeichnis. tar -xzf
backup.tgz -C /tst extrahiert
das Archiv in das Verzeichnis /tst. tar -xzf
backup.tgz '*.jpg' extrahiert
nur *.jpg-Dateien aus dem Archiv. oder Archiv
erstellen (-c create –f file Ziel Quelle): tar -cf
import_imagine_transfer_040924.tar * Archiv komprimieren (.9 höchster Komprimierungsgrad): gzip -9
import_imagine_transfer_040924 Archiv kontrollieren: cat import_imagine_transfer_040924.tar.gz
| gzip -d | tar -tf - | more |
||
|
ShellScript |
|
SQL-Abfrage
mit Rückgabewert (Sybase)
|
>isql |
|
ISQL_COMMAND="dump
database $SYB_DATABASE to '$DATABASE_PRE_SAVE'\ngo" ISQL_OUTPUT=`echo $ISQL_COMMAND | isql -S$SYB_SERVER
-D$SYB_DATABASE \
-U$SYB_USER -P$SYB_PASS -X -e | grep 'DUMP is complete' | wc -l` # Wenn eine Zeile im ISQL_OUTPUT mit
'DUMP is complete' vorkommt, dann wird # davon ausgegangen dass der Dump
erfolgreich war. if [ $ISQL_OUTPUT = 1 ] ; then MSG="`date '+%Y.%m.%d %T'` Datenbank
Dump vor EOD war erfolgreich" echo $MSG RC=0 else MSG="`date '+%Y.%m.%d %T'` Datenbank
Dump vor EOD ist fehlgeschlagen" echo $MSG RC=1 fi |
||
|
Sybase |
ShellScript |
>>man,
>>manpages, >>pages
Unix,
fuser
|
>fuser |
|
urpose Identifies processes using a file or file structure. Syntax fuser [ -c | -d | -f ] [ -k ] [ -u ] [ -x ] [ -V ]File
... Description The fuser command lists the process numbers of local
processes that use the local or remote files specified by the File
parameter. For block special devices, the command lists the processes that use
any file on that device. Each process number is followed by a letter
indicating how the process uses the file: c Uses the file as the current directory. e Uses the file as a program's executable object. r Uses the file as the root directory. s Uses the file as a shared library (or other
loadable object). The process numbers are written to standard output
in a line with spaces between process numbers. A new line character is written to
standard error after the last output for each file operand. All other output
is written to standard error. Flags -c Reports on any open files in the file system
containing File. -d Implies the use of the -c and -x flags. Reports
on any open files which haved been unlinked from the file system (deleted from the
parent directory). When used in conjunction with the -V flag, it also
reports the inode number and size of the deleted file. -f Reports on open instances of File only. -k Sends the SIGKILL signal to each local process.
Only the root user can kill a process of another user. -u Provides the login name for local processes in
parentheses after the process number. -V Provides verbose output. -x Used in conjunction with -c or -f, reports on
executable and loadable objects in addition to the standard fuser output. Examples 1. To list the process numbers of local processes
using the /etc/passwd file, enter: fuser
/etc/passwd 2. To list
the process numbers and user login names of processes using the
/etc/filesystems file, enter: fuser -u
/etc/filesystems 3. To
terminate all of the processes using a given file system, enter: fuser -k
-x -u /dev/hd1 - fuser
-kxuc /home Either command
lists the process number and user name, and then terminates each
process that is using the /dev/hd1 (/home) file system. Only the root user can
terminate processes that belong to another user. You might want to use this
command if you are trying to unmount the /dev/hd1 file system and a process
that is accessing the /dev/hd1 file system prevents this. 4. To list
all processes that are using a file which has been deleted from a given
file system, enter: fuser -d
/usr Files /dev/kmem Used for the system image. /dev/mem Also used for the system image. Related Information The killall command, mount command, and ps command. |
||
|
ShellScript |
|
Mehrere Prozesse eines Verzeichnisses stbnken (killen) |
>fuser |
|
Identifies processes using a file or file structure. fuser [ -c | -d | -f ] [ -k ] [ -u ] [ -x ] [ -V ]File
... The fuser command lists the process numbers of local
processes that use the local or remote files specified by the File
parameter. For block special devices, the command lists the processes that use
any file on that device. Bsp.: fuser -k
<Verzeichnis, von dem aus der Prozeß gestartet worden ist> -k Sends the SIGKILL signal to each local process.
Only the root user can kill a process of another user. |
||
|
ShellScript |
|
monitoring and tuning
tools, BOS functions and commands
|
>fuser |
|
iostat Reports
CPU and I/O statistics. vmstat
Reports
virtual-memory activity and other system statistics. netstat Displays the contents of
network-related data structures. ps Displays the status of
processes. lsattr
Displays
the attributes of devices. lslv
Displays
info about a logical volume or the logical volume allocations of a physical
volume. nfsstat
Displays
statistics about NetworkFileSystem (NFS) and RemoteProcedureCall (RPC)
activity. nice
Runs
a command at higher- or lower-than-normal priority. no Displays
or sets network options. renice
Changes
the priority of one or more processes. reorgvg
Reorganizes
the physical-partition allocation within a volume group. sar
Collects
and reports or records system-activity information. time
Prints
elapsed execution time, the user and system processing time attributed to a
command. trace
Records
and reports selected system events. |
||
|
ShellScript |
|
NIS-Tabellen ansehen, yellow pages (alter Projektname) |
>ypcat |
|
Prints out a Network Information Service (NIS) map. To Display the /usr/bin/ypcat [ -k ] [ -t ] [-d DomainName ]
MapName To Display the Nickname Translation Table /usr/bin/ypcat -x Description The ypcat command prints out the Network Information
Service (NIS) map you specify with the MapName parameter. You can specify
either a map name or a map nickname. Since the ypcat command uses the specify a server. Flags -k Displays the
keys for those maps in which the values are null or for which the key is not part of the value. (None of the maps
derived from files that have an ASCII version in the /etc directory fall into
this class.) -t Indicates that the name specified by the MapName
parameter is not a nickname. This flag causes the ypcat command to bypass the
nickname translation table and search only for the map specified by the MapName
parameter. -d DomainName Searches the specified domain for the
specified map. -x Displays the nickname translation table. This
table lists the map nicknames the command knows of and indicates the map name (as
specified by the MapName parameter) associated with each nickname. Bsp.: ypcat hosts (Ausschnitt) oftzai05:admin/WAN 216> ypcat hosts | grep zai 128.61.140.25
ofszai03 zn_prod1 zn_smp1
# SP Knoten 5 /wide node/ ZaiNet DB Server 128.61.140.26
ofszai04 zn_prod3 #
zn_prod1 zn_smp1 # J40/ZaiNet DB
BAckup Server 128.61.140.28
oftzai05 # 380
ZaiNet Testrechner Bsp.: ypcat -k netgroup oftzai05:admin/WAN 217> ypcat -k netgroup | grep
zainet zainet (,b74rz1,sohap) (,twsadmin,sohap)
(,informix,sohap) (,rsh_user,sohap) (,zainet,sohap) (,zntek,sohap) (,b60krr,sohap) (,b69krw,sohap) (,tape_op,sohap)
(,b12teu,sohap) (,b41laa,sohap) (,b78knl,sohap) (,b69hen,sohap)
(,b26hot,sohap) (,b57mum,sohap) (,b69old,sohap) (,b40xut,sohap)
(,b41hll,sohap) (,b66zen,sohap) (,b33gob,sohap) (,b33voi,sohap)
(,b42pit,sohap) (,b78grn,sohap) (,b78mag,sohap) (,b33zar,sohap)
(,b97sek,sohap) (,b60esr,sohap) (,b42pem,sohap) (,b66bni,sohap) (,b26rc1,sohap) (,b78sdl,sohap)
(,b26rc2,sohap) (,b78wan,sohap) (,b78jen,sohap) (,b78kov,sohap)
(,b42nil,sohap) (,b33buy,sohap) (,b26hut,sohap) (,b55mie,sohap)
(,b66kra,sohap) (,b67hhb,sohap) (,b40seg,sohap) # |
||
|
ShellScript |
|
System-Management |
>smitty |
|
SMIT (System Management Interface Tool) is an
interactive interface application designed to simplify system management
tasks. It displays a hierarchy of
menus that lead to interactive dialogs. Software
Installation and Maintenance Software
License Management Devices System
Storage Management (Physical & Logical Storage) Security
& Users
Communications Applications and Services Print Spooling Problem
Determination Performance
& Resource Scheduling System
Environments Processes
& Subsystems Applications RS/6000 SP
System Management Using SMIT (information only) |
||
|
ShellScript |
|
Prozess-Status, man pages |
>ps |
|
ps Command Purpose Shows current status of processes. This document
describes the standard AIX ps command as well as the System V version of the ps
command. Syntax X/Open Standards ps [ -A ] [ -N ] [ -a ] [ -d ] [ -e ] [ -f ] [ -k ]
[ -l ] [ -F format] [ -o Format ] [
-c Clist ] [ -G Glist ] [ -g Glist ] [ -m ] [ -n NameList ] [ -p Plist ] [
-t Tlist ] [ -U Ulist ] [ -u Ulist ] ps [ a ] [ c ] [ e ] [ ew ] [ eww ] [ g ] [ n ] [ U
] [ w ] [ x ] [ l | s | u | v ] [ t Tty ] [ ProcessNumber ] Description The ps command writes the current status of active
processes and (if the -m flag is given) associated kernel threads to standard
output. Note that while the -m flag displays threads associated with processes
using extra lines, you must use the -o flag with the THREAD field specifier to
display extra thread-related columns. Without flags, the ps command displays information
about the current workstation. The -f, -o, l, -l, s, u, and v flags
only determine how much information is provided about a process; they do not
determine which processes are listed. The l, s, u, and v flags are mutually
exclusive. With the -o flag, the ps command examines memory or
the paging area and determines what the command name and parameters were
when the process was created. If the ps command cannot find this
information, the command name stored in the kernel is displayed in square brackets. The COLUMNS environment variable overrides the
system-selected, horizontal screen size. The command-line flags that accept a list of
parameters (the -o, -G, -g, -p, -t, -U, and -u flags) are limited to 128 items. For
example, the -u Ulist flag can [ofapmxg04] { log } > ps v PID
TTY STAT TIME PGIN SIZE
RSS LIM TSIZ
TRS %CPU %MEM COMMAND 20064 pts/0 A
0:00 55
584 484 1048575 188
224 0.0 0.0 -ksh 21692 pts/1 A
0:00 0 196
148 1048575 3 4
0.0 0.0 tee -a l 50880 pts/4 A
0:00 106 612
480 1048575 188 224
0.0 0.0 -ksh 51112 pts/1 A
m 55856 pts/3 A
0:01 90 772
568 1048575 188 224
0.0 0.0 -ksh 58512 pts/4 A
0:00 0 736
240 1048575 188 224
0.0 0.0 -ksh 61946 pts/5 A
0:00 155 620
496 1048575 188 224
0.0 0.0 -ksh 64946 pts/7 A
0:00 15 600
240 1048575 188 224
0.0 0.0 -ksh 68480 pts/4 A
0:00 1 92
92 1048575 2 4
0.0 0.0 clnproc 74688 pts/1 A
0:00 31 596
800 1048575 188 224 0.0
0.0 -ksh 78212 pts/4 A
0:01 344 2996
4580 1048575 2826 1584
0.0 0.0 ./olkvi e 81042 pts/18
A 0:00 9
604 600 1048575 188
224 0.0 0.0 -ksh 85256 pts/8 A
0:00 0 580
788 1048575 188 224
0.0 0.0 -ksh 93486 pts/4 A
0:00 0 640
708 1048575 52 68
0.0 0.0 ps v 101678 pts/4 A
0:00 47 592
816 1048575 774 224
0.0 0.0 ./mxwex p PID (all flags)
The process ID of the process. TTY (all flags)
The controlling workstation for the process: - The
process is not associated with a workstation. Number The TTY
number. For example, the entry 2 indicates TTY2. STAT (s, u, and v flags) Contains the state of the
process: 0 Nonexistent, A Active, I
Intermediate, Z Canceled, T Stbnked, K Available kernel process TIME (all) The total
execution time for the process. PGIN (v flag) The
number of disk I/Os resulting from references by the process to pages not
loaded in core. SIZE (v flag) The
virtual size of the data section of the process (in 1KB units). RSS (v flag) The
real-memory (resident set) size of the process (in 1KB units). LIM (v flag) The
soft limit on memory used, specified via a call to the setrlimit subroutine.
If no limit has been specified, then shown as xx. If the limit is set to the
system limit, (unlimited), a value of UNLIM is displayed. TSIZ (v flag) The
size of text (shared-program) image. TRS (v flag) The
size of resident-set (real memory) of text. %CPU (u and v
flags) The percentage of time the process has used the CPU since the process
started. %MEM (u and v
flags) The percentage of real memory used by this process. COMMAND (s, u, and
v) Contains the command name. The full command name and its parameters
are displayed with the -f flag. Flags: -a Writes to standard output information about all
processes, except the session leaders and
processes not associated with a terminal. -e Writes information to standard output about all
processes, except kernel processes. -f Generates a full listing. -l Generates a long listing. See also the l flag. -o Format Displays information in the format
specified by the Format variable. Multiple
field specifiers can be specified for the Format variable. The Format variable is
either a comma-separated list of field specifiers or a list of field specifiers
enclosed within a set of " " (double-quotation marks) and separated from one
another by a comma or by one or more spaces, or both. v Displays the PGIN, SIZE, RSS, LIM, TSIZ, TRS,
%CPU, %MEM fields. |
||
|
ShellScript |
|
Auswertung
von Config - Files
|
>eval |
|
Mit eval kann man einen z.Bsp. gegreppten
Befehl ausführen. Bsp.: in
einen File BLA steht VAR=123 mit
CMD=`grep VAR BLA`wird CMD mit der Zeile aus dem File BLA belegt, mit eval
$CMD wird der Inhalt der Zeile ausgeführt. $VAR ergibt
dann 123. |
||
|
ShellScript |
|
Befehlshistorie
|
>history |
|
mit dem
Befehl history (-)Zahl kann man sich die (letzten) Zahl Befehle ansehen history -10
(gibt die letzten 10 Befehle) |
||
|
ShellScript |
|
>>cvs,
>>CVS
Vorgehen aus- und >ein>checken >Release, >Branch, . . . |
>cvs |
2004 |
1.) Umgebungsvariablen für
Entwicklungsumgebung setzen: .
setenv_devel 2.) Unterverzeichnis unter dem
develop-Verzeichnis anlegen, z.B. „work_eric“ 3.) [ofapmxg04] {
/opt/backup/archive/develop/work_eric/olk_xml_adapter } > ll 4.) Die Source-Dateien sind aufgeteilt
auf perl, shell und c++ 5.) Vor dem Installieren per make muss der ROOT-Pfad im Makefile
angepasst werden: 6.) Änderungen an den Sourcedateien
vornehmen . . . 7.) cvs
diff –c
<Dateiname> oder –r „Branchname“ oder –r „Releasename“ zum Ansehen der
Änderungen 8.) cvs
update zum
Aktualisieren der ausgecheckten Dateien vor dem wiedereinchecken &
Ausgabe der geänderten Dateien: M . . . modifiziert, U . . . updated 9.) cvs
commit um die
Änderungen wieder einzupflegen 10.)
cvs –q status 11.)
cvs –q log zum Ansehen der Änderungen 12.)
Bsp.: Auschecken
dyn_hedge: cvs checkout –d dynamic_hedge –r BRANCH_TWS_ready olk_xml_adapter 13.)
Bsp.: Unterschiede Branches: cvs diff –r
BRANCH_TWS_ready –r DEV_PepDynamicHedge 14.)
|
||
Versionskontrolle, Source Code Versionen |
ShellScript |
|
Beispiel „BRANCH_DDF_NDF“, >branch |
>cvs |
02.12.2004 |
1.) Umgebungsvariablen für
Entwicklungsumgebung setzen: 2.)
Unterverzeichnis
unter dem develop-Verzeichnis anlegen, z.B. 3.) „branch“- Tag im Release „PROD_MM_TDB_3“ mit der Bezeichnung
“BRANCH_DDF_NDF” setzen 4.) Diesen Branch dann auschecken, damit
auf Basis dieser weiterentwickelt werden kann 5.) Änderunmgen vornehmen in den
Quelldateien, hier OlkXmlImportMappings.xml 6.) cvs
diff o. cvs diff –r“BRANCH_DDF_NDF“ o. cvs
diff –r“PROD_MM_TDB_3“ (sollte
gleich sein ) 7.) cvs
update zum
Aktualisieren der ausgecheckten Dateien vor dem wiedereinchecken 8.) cvs
ci um die
Änderungen wieder einzupflegen (woraus es ausgecheckt war) |
||
Versionskontrolle, Source Code Versionen |
ShellScript |
|
Übersicht, Paramater, checkin, checkout, >OLK-XML, >XML |
>cvs |
|
CVS commands are:
add Add a new
file/directory to the repository
admin Administration
front end for rcs
annotate Show last revision
where each line was modified checkout,co Checkout sources for editing commit Check files into the repository diff Show differences between revisions
edit Get ready to edit a
watched file
editors See who is editing
a watched file
export Export sources from
CVS, similar to checkout
history Show repository
access history
import Import sources into
CVS, using vendor branches
init Create a CVS
repository if it doesn't exist
log Print out history
information for files
login Prompt for password
for authenticating server
logout Removes entry in
.cvspass for remote repository
pserver Password server
mode
rannotate Show last revision
where each line of module was modified
rdiff Create 'patch'
format diffs between releases
release Indicate that a
Module is no longer in use
remove Remove an entry
from the repository
rlog Print out history
information for a module
rtag Add a symbolic tag
to a module
server Server mode
status Display status
information on checked out files
tag Add a symbolic tag
to checked out version of files unedit
Undo an edit command
update Bring work tree in
sync with repository
version Show current CVS
version(s)
watch Set watches
watchers See who is watching
a file Usage: cvs checkout [-ANPRcflnps] [-r rev]
[-D date] [-d dir] [-j rev1]
[-j rev2] [-k kopt] modules...
-A Reset any sticky
tags/date/kopts.
-N Don't shorten module
paths if -d specified.
-P Prune empty directories.
-R Process directories
recursively.
-c "cat" the
module database.
-f Force a head revision
match if tag/date not found.
-l Local directory only,
not recursive
-n Do not run module
program (if any).
-p Check out files to
standard output (avoids stickiness).
-s Like -c, but include
module status. -r rev Check out revision or tag. (implies -P) (is
sticky) -D
date Check out revisions as of date. (implies -P) (is sticky) -d dir Check out into dir instead of module name. -k
kopt Use RCS kopt -k option on checkout. (is sticky) -j
rev Merge in changes made between
current revision and rev. Usage: cvs commit [-Rlf] [-m msg | -F
logfile] [-r rev] files... -R
Process directories recursively. -l Local directory only (not
recursive). -f Force the file to be committed;
disables recursion. -F
logfile Read the log message from
file. -m
msg Log message. -r rev Commit to this branch or trunk
revision. |
||
Versionskontrolle, Source Code Versionen |
ShellScript |
|
cvs Hilfe, help, z.Bsp.
checkout, diff
|
>cvs |
|
[ofapmxg04] {
/opt/backup/archive/develop/work_eric/olk_xml_adapter/perl } > cvs --help
diff Usage: cvs
diff [-lR] [-k kopt] [format_options] [[-r rev1
| -D date1] [-r rev2 | -D date2]] [files...]
-l Local directory only,
not recursive
-R Process directories
recursively. -k
kopt Specify keyword expansion mode. -D d1
Diff revision for date against working file. -D
d2 Diff rev1/date1 against date2. -r
rev1 Diff revision for rev1 against working file. -r
rev2 Diff rev1/date1 against rev2. format_options: -i --ignore-case Consider upper- and lower-case to be the
same. -w --ignore-all-space Ignore all white space. -b --ignore-space-change Ignore changes in the amount of white
space. -B --ignore-blank-lines Ignore changes whose lines are all blank. -I RE --ignore-matching-lines=RE Ignore changes whose lines all match RE.
--binary Read and write data in
binary mode. -a --text
Treat all files as text. -c -C NUM
--context[=NUM] Output NUM
(default 2) lines of copied context. -u -U NUM
--unified[=NUM] Output NUM
(default 2) lines of unified context. -NUM Use NUM context lines. -L
LABEL --label LABEL Use LABEL instead of file name. -p --show-c-function Show which C function each change is in. -F RE --show-function-line=RE Show the most recent line matching RE. --brief Output only whether files differ. -e --ed
Output an ed script. -f --forward-ed Output something like an ed script in
forward order. -n --rcs
Output an RCS format diff. -y --side-by-side Output in two columns. -W
NUM --width=NUM Output at most NUM (default 130) characters
per line.
--left-column Output only the
left column of common lines.
--suppress-common-lines Do not
output common lines.
--ifdef=NAME Output merged file
to show `#ifdef NAME' diffs.
--GTYPE-group-format=GFMT
Similar, but format GTYPE input groups with GFMT.
--line-format=LFMT Similar, but
format all input lines with LFMT.
--LTYPE-line-format=LFMT
Similar, but format LTYPE input lines with LFMT. LTYPE is
`old', `new', or `unchanged'. GTYPE is
LTYPE or `changed'. GFMT may
contain:
%< lines from FILE1
%> lines from FILE2 %= lines common to FILE1 and FILE2
%[-][WIDTH][.[PREC]]{doxX}LETTER
printf-style spec for LETTER LETTERs
are as follows for new group, lower case for old group:
F first line number
L last line number
N number of lines = L-F+1
E F-1
M L+1 LFMT may
contain: %L contents of line %l contents of line, excluding any trailing
newline
%[-][WIDTH][.[PREC]]{doxX}n
printf-style spec for input line number Either
GFMT or LFMT may contain: %% %
%c'C' the single character C
%c'\OOO' the character with
octal code OOO -t --expand-tabs Expand tabs to spaces in output. -T --initial-tab Make tabs line up by prepending a tab. -N --new-file
Treat absent files as empty. -s --report-identical-files Report when two files are the same.
--horizon-lines=NUM Keep NUM
lines of the common prefix and suffix. -d --minimal
Try hard to find a smaller set of changes. -H --speed-large-files Assume large files and many scattered small
changes. |
||
Versionskontrolle, Source Code Versionen |
ShellScript |
|
>>awk,
>>AWK
akw
- Script mit Berechnung
|
>awk |
|
Bsp.
Quelldatei: fxsp:spot;CAD;EUR;EUR-CAD;1.000000; 1.5647000 rm erik.txt DATE="`date +%d/%m/%Y` " TIME="`date +%I%M`" EURUSD=`cat spot_ex.mpprn | grep USD | cut -d";" -f6 | tr -d ' ' ` USDEUR=`echo "scale=10;(1/$EURUSD)" | bc` exec 3<"QUELLDATEI" while read -u3 zeile do echo "$DATE;$TIME;$USDEUR;$zeile"
| grep -v USD | awk -F";"
'{printf("%s %s %s USD / %010.8f
\n",$1,$2,$5,1/($9*$3))}' >> erik.txt Hier
beachten: Damit der awk die ersten bnki Variablen ($DATE, $TIME usw.)
berücksichtigt, müssen sie mit dem selben Trennzeichen -F";"
getrennt werden wie die "QUELLDATEI". Im
{printf(... müssen dann der Reihe nach die Ausgabeformate der Felder
spezifiziert werden, die dann nach \n" angegeben werden. $1 entspricht dann $DATE (siehe
Trennzeichen...). Wichtig:
Es müssen so viele Ausgabeformate definiert sein, wie ausgegeben werden
sollen. done exec 3<&- echo "$DATE $TIME EUR USD / $EURUSD"
>> erik.txt |
||
|
ShellScript |
|
awk
(Skriptsprache zur Mustererkennung) ausführen
|
awk |
|
Einfach das
erste und zweite Datenfeld aus jeder Zeile der Datei 'prcfwd_f.prd.txt'
ausgeben. Trennngszeichen ist '|' cat prcfwd_f.prd.txt | awk -F\| '{
print $1,$2 }' Nutzen vom
BEGIN-Statement, um vorab Variablen zu setzen. Hier: Eingabetrennzeichen,
Ausgabetrennzeichen cat img.storni.dat | awk 'BEGIN
{FS="\|";OFS="\|"} {print $11,$12,$13,$14,$15,$16,$17}' Prozeß-ID Jobs bestimmen JOB=`ps -fea
| grep -i job | grep -v grep | awk ' { print $2} '` PORTS=`cat
$ZNDIR/LOG/used_zainet_ports | awk '{if ($1 == "PORT") print $2}'` JOBS=`cat
$ZNDIR/LOG/used_zainet_ports | awk '{if ($1 == "JOB") print $5}'` JobCount=`echo
"select count(*) from job where job_rt=JOBB" | \ $INFORMIXDIR/bin/isql $ZNDBS
- 2>/dev/null | awk '/[0-9][0-9]*/ {print $0}' - ` find $ZNDIR/admin/WAN -ls
2>/dev/null | awk ' { print $7, "\t", $11 }' | sort -n >
abc.$$ Umformatierung eine Datumsfeldes von '' nach '': DATUM=`echo
$DATUM | awk '{ printf "%s%s", substr($1,1,5), substr($1,8,2) }'` Umformatierung
eine Datumsfeldes von '02/25/2002' nach '2002-02-25': DATUM=`echo $DATUMIN | awk
-F"/" ' { print $3"-"$1"-"$2 } ' ` TIME=`echo
$TIMEIN | awk ' { printf ( "%02s.%02s.00", substr($0,1,2),
substr($0,3,2) ) } ' ` TIME=`echo
$TIMEIN | awk ' { printf ( "0%s.%s.00", substr($0,1,2),
substr($0,3,2) ) } ' ` Datum=$1 Tag=`echo $Datum | awk ' { print
substr($0,1,2) } '` Monat=`echo $Datum | awk ' { print
substr($0,3,3) } ' ` Jahr=`echo $Datum | awk ' { print
substr($0,6,2) } ' ` Monat=`echo
$Monat | tr '[A-Z]' '[a-z]'` echo "$Monat/$Tag/$Jahr" |
||
|
AWK |
|
Zeilenzähler
generieren und in Datei einfügen |
awk |
|
BEGIN { integer i }
{
i = i + 1
printf("%6d|%s\n", i, $0)
}
Aufruf aus
einem Skript: awk -f
row_id.awk $DATA_DIR/$ZN_FILE.$TAG.dat > $DATA_DIR/$ZN_FILE.ing |
||
|
|
|
Beispiel Hans-Peter, intra day value at risk |
awk |
|
FILE=$1 grep
"Fx PL EUR/" $FILE | grep -v Central | cut -d';' -f 3,4,5,6 |
sort | \ awk
-F";" 'BEGIN { "date
\"+%d/%m/%Y,%H:%M:%S\"" | getline date0; max_var = 10000000; var = max_var; } { split($1, col1, " "); split(col1[4], col2, "/"); grp1 = col1[4] col1[5]; var0 = var; if(grp1 !=
grp0 && grp0 != "") var = max_var; if($2 <
var) var = $2; if($3 <
var) var = $3; if($4 <
var) var = $4; if(grp1 !=
grp0) { if(grp0 !=
"") { # seek
for (Central) cur0/cur1 in inputfile and store 2nd value as delta loop =
1; delta =
0; do {
getline line < "'$FILE'";
split(line, col3, ";");
split(col3[3], col4, " "); if(col3[2]
== "(Central)" && col4[3] == cur0 "/" cur1
&& book0 == col4[4]) {
delta = col3[5]; loop
= 0; } } while
(loop);
close("'$FILE'");
printf("%s %s %s %s %20.2f %20.2f\n", date0,
book0, cur1, cur0, delta, var0); } grp0 =
grp1; book0 =
col1[5]; cur0 =
col2[1]; cur1 =
col2[2]; } } END { loop = 1; delta = 0; do { getline
line < "'$FILE'";
split(line, col3, ";");
split(col3[3], col4, " "); if(col3[2]
== "(Central)" && col4[3] == cur0 "/" cur1
&& book0 == col4[4]) { delta =
col3[5]; loop =
0; } } while
(loop);
close("'$FILE'");
printf("%s %s %s %s %20.2f %20.2f\n", date0, book0, cur1,
cur0, delta, var0) ; }' | sed "s/FX-DD01/OPD1/g" | sed
"s/FX-DD02/OPD2/g" > tst.txt ### EOF ### |
||
|
|
|
printf,
Multiplizieren * |
awk |
17.122001
|
exec 3<$DateiName while read -u3 zeile do echo $zeile | awk -F"|"
'{printf("%s%s!%s!%s!%s!%s!%09.4f!%09.4f!%09.4f!
!\n",$5,$2,$3,$6,"00",$7, $8/1000,$9/1000,$10/1000)}' done exec
3<&- |
||
führende Null bei formatierter Ausgabe |
SQL |
|
Rechnen |
awk |
|
in einer
Shell mit lokalen Variablen: ONPRC=`echo "$SPPRC $W1PRC" | awk ' BEGIN {} {
a=$1;b=$2;erg=a-b;printf (" %f ",erg) } END {} ' `
|
||
|
SQL |
|
admin/XEN/fame/markup_import.awk |
awk |
06.02.02
|
/VO/,/RC/{ if ($14 ~ /VO/){ for (i=4;i
<= 12; i++) Interval[i]
= $i print } if ($14 ~ /RC/){ for (i=4;i
<= 12; i++) if ( $i ==
"") $i =
Interval[i] printf("%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17,$18,$19,$20,$21,$22,$23,$24) } } |
||
|
|
|
admin/XEN/fame/report.awk |
awk |
06.02.02
|
/^MARGIN CLASS:/,/EUREX/{ if ($1 ~
/MARGIN/) product=$3 if ($1 ~
/^[C,P]/ && NF==8) printf("%s
%s %s %s %6d
%12.2f%15.4f%9.2f%14.2f%7.2f%\n",$1,product,substr($2,1,3),substr($2,4,2),$3,$4,$5,$6,$7 ,$8) } |
||
|
|
|
Programm |
awk |
|
# lepos.awk #
26-Jan-2000 KLZ Dient der Findung und
Eliminierung der Lepos # beim Erzeugen des Vola-Files fuer FAME. BEGIN {
getline; print } { cont_data
= substr($0,1,14) #
String mit allen notwendigen Kontraktdaten contract
= substr($0,3,7) #
nur der Kontraktname (z.B. "SAP3" oder "DCX" strike
= substr($0,15,5) #
der Strike Price daten
= substr($0,20,150) #
die restliche Daten stock_price =
substr($0,22,19) # Preis des
Underlying sett_price
= substr($0,49,14) #
Preis der Option/Future put_call = substr($0,0,1) # Schweizer
Lepos: strike immer mit " 1
" dargestellt if (strike == " 1") sub(" 1","0.001",strike) # substituiere die " 1 " im
Strike mit "0.001" # Deutsche
Lepos: Strikes mit impizierten Dezimalstellen, immer " 100 " # 1) erst mal die Calls if ((strike
== " 100") &&
(stock_price - sett_price < 2)) sub(" 100","0.001",strike) # 2) nun
die Puts, das ist nicht so einfach und birgt folgenden Fehlerfall: # Koennte sein, dass strike = 100 ist und
die Aktie weit darueber notiert, dann sind # theoretisch auch Optionspreise von 0.01
mgl. if ((strike == " 100") && (put_call ==
"P") && (sett_price == " 0.01
")) sub(" 100","0.001",strike) # 3)
Sonderfall SAP: Strike-Preise implizierte Nachkommastelle. # 3.1) erst fuer Calls if ((strike
== " 10") &&
(stock_price - sett_price < 2) && (contract = "SAP3 "))
sub("
10","0.001",strike) # 3.2) nun Puts if ((strike
== " 10") &&
(put_call == "P") && (sett_price == " 0.1
") && (contract = "SAP3 ")) sub(" 10","0.001",strike) # Und nun
wird alles ausgegeben... out = cont_data strike daten print out } |
||
|
|
|
|
awk, if |
|
BEGIN { integer i } { printf(
"%s%s%s%s%s%s%s%s%s%s%s",$1,",",$2,",",$3,$4,",",$5,",",substr($0,21,2),",") if ( substr($0,21,2) == " " ) printf
("%s%s%s%s%s%s%s%s%s\n",$6, ",", $7,",",$8,
",",$9,",",$10) else printf
("%s%s%s%s%s%s%s%s%s\n",$7, ",", $8,",",$9,
",",$10,",",$11) } |
||
|
|
|
beispiel |
awk |
|
BEGIN { getline; print } { cont_data
= substr($0,1,14) #
ist der String mit allen notwendigen Kontraktdaten contract
= substr($0,3,7) #
nur der Kontraktname (z.B. "SAP3" oder "DCX" strike
= substr($0,15,5) #
der Strike Price daten
= substr($0,20,150) #
die restliche Daten stock_price =
substr($0,22,19) # Preis des
Underlying sett_price
= substr($0,49,14) #
Preis der Option/Future put_call = substr($0,0,1) #
fuer schweizer Lepos ist es einfach; hier ist der strike immer mit
" 1 " dargestellt if (strike == " 1") sub(" 1","0.001",strike) # substituiere die " 1 " im
Strike mit "0.001" #
fuer deutsche Lepos werden strikes mit impizierten Dezimalstellen gesendet,
immer " 100 " #
beachte: unterschied. Preise bei Put(immer fast 0.0) und Call(immer nahazu
Aktinskurs) #
1) erst mal die Calls if ((strike == " 100") && (stock_price -
sett_price < 2)) sub(" 100","0.001",strike) #
2) nun die Puts, das ist nicht so einfach und birgt folgenden Fehlerfall: # Es koennte sein, dass strike = 100 ist
und die Aktie weit darueber notiert, dann sind # theoretisch auch Optionspreise von 0.01
mgl. # Das ist aber nur sehr theoretisch. In der
Praxis sollte das nicht vorkommen, da # EUREX alle Serien, die weit aus dem Geld
sind und keinen "open interest" haben, loescht. if ((strike == " 100") && (put_call ==
"P") && (sett_price == " 0.01
")) sub(" 100","0.001",strike) #
3) Leider gibt es den Sonderfall SAP. Hier haben die Strike-Preise ja nur
eine (implizierte) Nachkommastelle. # Das muss jetzt extra bearbeitet werden. #
3.1) erst fuer Calls if ((strike == " 10") && (stock_price -
sett_price < 2) && (contract = "SAP3 ")) sub(" 10","0.001",strike) #
3.2) nun Puts if ((strike == " 10") && (put_call ==
"P") && (sett_price == " 0.1
") && (contract = "SAP3 ")) sub(" 10","0.001",strike) #
Und nun wird alles ausgegeben... out =
cont_data strike daten print out } |
||
|
|
|
beispiel |
awk |
|
/VO/,/RC/{ if ($14 ~
/VO/){ for (i=4;i <= 12; i++) Interval[i] = $i print } if ($14 ~
/RC/){ for (i=4;i <= 12; i++) if ( $i == "") $i = Interval[i] printf("%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s;%s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$ 17,$18,$19,$20,$21,$22,$23,$24) } } |
||
|
|
|
beispiel |
awk |
|
/PRODUCT
ID:/,/EUREX/{ if ($1 ~ /MARGIN/) product=$9 if ($1 ~ /^[C,P]/ && NF==8) { gsub( /,/, "", $7 ); printf("%1s %-4s %3s %2s %5s %12s
%15.4f %8s %13.2f %6.2f%\n", \ $1, product, substr($2,1,3),
substr($2,4,2), $3, $4, $5, $6, $7, $8 ); } } |
||
|
|
|
Auf
Muster prüfen, z.B. Leerzeichen oder Großbuchstaben
|
awk |
|
cat
ssi_zainet4.csv | awk -F ";" ' $41 ~ /[A-Z]+/ { print
"Zeichen" } ' |
||
|
awk |
|
bsp, Schleife |
awk |
|
BEGIN { integer i } { i = i
+ 1
printf("%6d|%s\n", i, $0) } |
||
|
|
|
Beispiel |
awk |
|
awk -F";" '{if((($2=="*") &&
($1=="2"))||(($2=="/") &&
($1=="1"))){printf("invers\n")}else{printf("\n")}}'
opt.14a > opt.14b
|
||
|
|
|
>>sed,
>>SED
sed
(stream editor – zeichenstrom-orientierter Editor)
|
sed |
|
Definiert
eine erste Gruppe \...\ bestehend aus "bnki Großbuchstaben= 1",
löscht diese inklusive der darauffolgenden beliebigen Zeichen "."
und davon beliebig viele "*" und ersetzt diese (alles) mit der
Gruppe selbst "/1". s/\([A-Z][A-Z][A-Z]= 1\).*/\1/g Definiert
eine erste Gruppe \...\ bestehend aus "bnki Großbuchstaben", löscht
diese inklusive der darauffolgenden beliebigen Zeichen "." und
davon beliebig viele "*" und ersetzt alles durch die Gruppe, einem
Gleichheitszeichen '=' einem Blank, einer Eins '1' und nocheinmal die Gruppe
(Bnki Großbuchsteban) s/\([A-Z][A-Z][A-Z]\).*/\1= 1 \1 SP/g auszuführen
wie folgt (Kommndozeile): `sed
"s/\([A-Z][A-Z][A-Z]= 1\).*/\1/g" $TmpFileIn > $TmpFileOut` oder auch (Kommndozeile): sed "s/\([A-Z][A-Z][A-Z]=
1\).*/\1/g" $TmpFileIn > $TmpFileOut Punkt
durch Komma ersetzen: sed
's/\./,/g' $ZNSAV/REPORTS/SAVE.$DATUM/$ZNFILE_IN >
$ZNSAV/REPORTS/SAVE.$DATUM/$ZNFILE_OUT.tmp sed 's/|$//g'
$ZNSAV/REPORTS/SAVE.$DATUM/$ZNFILE_OUT >
$ZNSAV/REPORTS/SAVE.$DATUM/$ZNFILE_OUT.tmp rc=`$RSH
$REM_HOST -l $REM_USER $REMRIPDIR/$REMRIPSCRIPT $REMRIPDIR/cfg/$RIPCFGF | sed
'$!d'` Zahlenfolge
aufbesseren für nachträgliches sortieren: vorher:
A.C1.ProcessedFile8=/opt/curplus/today/ins_4106787_fx_fut.xml nachher: A.C1.ProcessedFile008=/opt/curplus/today/ins_4106787_fx_fut.xml |
||
|
sed |
|
Zeichenfolgen
in Datei ersetzen
|
sed |
|
#---------------------------------------------------------------------------------------- # Correct the ascii to ebcdc converting error by
using substitutes #---------------------------------------------------------------------------------------- PIPE="##PIPE##" BRACKOP="##BRACKOP##" BRACKCL="##BRACKCL##" `sed "s/|/$PIPE/g" $TmpFile > $
TmpFile1` `sed "s/\[/$BRACKOP/g" $TmpFile1 >
$TmpFile2` `sed "s/\]/$BRACKCL/g" $TmpFile2 >
$TmpFile` |
||
|
ShellScript |
|
An
Satz etwas anhängen
|
sed |
|
`sed "s/$/||/g" $IMG_STORNI >
$IMG_STORNI.tmp` mv
$IMG_STORNI.tmp $IMG_STORNI |
||
|
sed |
|
Leere
Zeilen löschen, Leerzeilen, empty rows
|
sed |
|
`sed "/^$/d" $IMG_STORNI >
$IMG_STORNI.tmp` mv
$IMG_STORNI.tmp $IMG_STORNI |
||
|
sed |
|
>Anzahl
Zeichen bzw. Datenfelder zählen, >count, >zählen
|
expr |
|
NUMDEL=`sed "s/[^|]//g" $IMG_STORNI | wc
-c` NUMDEL=`expr
$NUMDEL - 1` NUMREC=`cat
$IMG_STORNI | wc -l` if [ $NUMREC
-gt 0 ]; then
NUMDAT=`expr $NUMDEL / $NUMREC` show_log
"Number of data fields of '`basename $IMG_STORNI`: $NUMDAT\n" else show_log
"Empty file '`basename $IMG_STORNI`.\n" fi Anzahl
Trennzeichen zählen: NB_FLDS=`cat $IMPORT_DDF_DIR/$NEWTRADES | sed
"s/[^!]//g" | wc -c` |
||
|
sed |
|
Datum
'TTMMYY' umformatieren in 'YYYYMMTT'
|
sed |
|
DATUM=`echo
$DATUM | sed "s/^\([0-9][0-9]\)\([0-9][0-9]\)\([0-7][0-9]\)/20\3\2\1/g` DATUM=`echo
$DATUM | sed "s/^\([0-9][0-9]\)\([0-9][0-9]\)\([8-9][0-9]\)/19\3\2\1/g` |
||
|
sed |
|
Konstante
oder Leerzeichen vor Zeichenkette setzen
|
sed |
|
DEPOT=`echo $DEPOT | sed "s/^\(.*\)/DEPOT
\1/g"` DEPOT=`echo $DEPOT | sed "s/^\(.*\)/ \1/g"` |
||
|
sed |
|
Beispiel
sed-Datei benutzen, >Monat, >Jahr
|
sed |
|
Aufruf aus Skript: `sed -f$SEDDDFSWAPS1 $RIPSWAPSIN >
$DDFSWAPSOUT.tmp` sed-Datei: s/ /|/g s/,/./g s/|Jan|/|-01-/g s/|Feb|/|-02-/g s/|Mar|/|-03-/g s/|Apr|/|-04-/g s/|May|/|-05-/g s/|Jun|/|-06-/g s/|Jul|/|-07-/g s/|Aug|/|-08-/g s/|Sep|/|-09-/g s/|Oct|/|-10-/g QuotDate=`echo
"${QuotTmp2}" | sed
"s/^\([0-9][0-9]\)\([A-Z][A-Za-z][A-Za-z]\)\([0-9][0-9][0-9][0-9]\).*/\3\2\1/g"
\ | sed
"s/JAN/01/;s/FEB/02/;s/MAR/03/;s/APR/04/;s/MAY/05/;s/JUN/06/; \ s/JUL/07/;s/AUG/08/;s/SEP/09/;s/OCT/10/;s/NOV/11/;s/DEC/12/;
\ s/Jan/01/;s/Feb/02/;s/Mar/03/;s/Apr/04/;s/May/05/;s/Jun/06/;
\ s/Jul/07/;s/Aug/08/;s/Sep/09/;s/Oct/10/;s/Nov/11/;s/Dec/12/"` |
||
|
sed |
|
Sybasedatum
"24 Aug 1996 12:00 AM" => Codebaseformat "24/08/96"
|
sed |
17.01.02
|
s/\(
\)\([A-Z][a-z][a-z]\)\( \)\([0-9][0-9]\)\( \)\([1-2][0-9]\)\([0-9][0-9]\)\(
12:00AM\)/\4\/\2\/\7/g Es
wird der gesamte zu ersetztende Ausdruck nach dem "s/..." durch
mehrere Gruppen "\(...\)" nachgebildet und diese in geigneter
Reihefloge vor dem ".../g" wieder zusammgefügt. Wesentlich ist, das
jeder eindeutige Teil des zu ersetzenden Musters als eine eigene Gruppe
nachgebildet wird, damit diese Gruppe entweder wiederverwendet oder aber auch
nicht mehr berücksicht werden kann. Im
obigen Beispiel soll die '24' als Tag, der 'Aug' als Monat und die letzten
beiden Zahlen des '1996' mit '/' getrennt dargestellt werden. Damit keine
Leerzeichen mitgenommen werden, werden diese als eigen Gruppen defioniert und
nicht weiter berücksichtigt. Die '24' ist also die Gruppe Nr. 2, der Tag die
Gruppe Nr.4 und die letzten beiden Zahlen des Jahres schließlich die Gruppe
der Nr. 7, jeweils getrennt durch ein Schrägstrich. Der Monat wird in einem
nächsten Schritt anlog obigem Vorgehen ersetzt. |
||
|
sed |
|
Steuerungszeichen
|
sed |
17.01.02
|
Sollen
Steuerungs bzw. Sonderzeichen ersetzt werden, müssen dies mit der
Seuerungstaste + V + Sonderzeichen durch die Tastatur erzeugt werden; sie
entspricht nicht dem Dachsymbol !!! Beispielsweise
"Strg + V + M" für den Zeilenumbruch (Steuerungstaste festhalten) |
||
|
sed |
|
Zeile löschen, Leerzeichen durch Trennungszeichenersetzen |
sed |
|
# loesche unnoetige Zeilen
cat
$MXG2000_DIR/$LOCAL_FILE | sed "/^.[\/,(c),BNKENHEIM, ]/d" > $TEMP/$LOCAL_FILE # loesche
horizontale Liniensonderzeichen
cat
$TEMP/$LOCAL_FILE | sed "s/[,>ÃÄÂÁÅÐÒÀÀÙÙÚÀ¿Í»Éȼ×^M^L]//g" >
$TEMP/$LOCAL_FILE.$$ # ersetze
vertikale Liniensonderzeichen
cat $TEMP/$LOCAL_FILE.$$ | sed "s/[³º]/ /g" > $TEMP/$LOCAL_FILE # ersetzte
1 bis 32 Leerzeichen durch ein Semikolon als Trennungszeichen
cat
$TEMP/$LOCAL_FILE | sed "s/\{1,32\}/;/g" > $TEMP/$LOCAL_FILE.$$ # ersetzte
schliesslich punkt durch Komma für Excel-Sheet
cat $TEMP/$LOCAL_FILE.$$
| sed "s/\./,/g" > $MXG2000_DIR/$LOCAL_FILE |
||
|
ShellScript |
|
Jeweils ersten >Buchstaben >gross, Rest >klein schreiben |
sed |
|
cat
$1 | \ sed
"y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" | \ sed
"s/\([a-z]\)\([a-z][a-z]*\)/\1#\2/g" | \ sed
"s/a#/A/g;s/b#/B/g;s/c#/C/g;s/d#/D/g;s/e#/E/g;s/f#/F/g;s/g#/G/g;s/h#/H/g;s/i#/I/g;s/j#/J/g;s/k#/K/g;s/l#/L/g;s/m#/M/"
| \ sed
"s/n#/N/g;s/o#/O/g;s/p#/P/g;s/q#/Q/g;s/r#/R/g;s/s#/S/g;s/t#/T/g;s/u#/U/g;s/v#/V/g;s/w#/W/g;s/x#/X/g;s/y#/Y/g;s/z#/Z/"
\ > ~/$1.Abc |
||
Formatierung |
ShellScript |
|
>>svn
>subversion, >infra1.de.bnksdnerkb.com
|
>svn |
19.12.2005 |
0.) Es soll das Versionierungsprogramm
‚svn’ - subversion implementiert/benutzt werden 1.) Installiert ist svn auf der
‚infra1.de.bnksdnerkb.com’; Zugang als ‚f985757’ übliche passwd 2.) Pfade Profile (z.B. murdev.de.bnksdnerkb.com
- \\murdev.de.bnksdnerkb.com\f985757) ergänzen: 3.) Verzeichnis anlegen, z.B.
/home/f985757/dealbus 4.) svn help : Befehlsübersicht 5.) svn co
http://mxcomsvn:666/svn/mxmlPress/ . : akt. Stand Projekt ‚mxmlPress’ auschecken 6.) svn co http://mxcomsvn:666/svn/mxmlPress/trunk
. : nur Arbeitsversion auschecken 7.) svn status : Status ansehen 8.) svn add bla.txt : Datei zur eigenen
lokalen Arbeitsversion ergänzen 9.) svn commit bla.txt : Datei in
Repository hochladen – wird dadurch gültig und sichtbar 10.)
svn
delete bla.txt : Datei aus eignene lokalen Arbeitsversion löschen 11.)
svn
commit bla.txt : Datei im Repository löschen - wird dadurch gültig und
sichtbar 12.)
svn
status : Erneut Status ansehen 13.)
svn
diff ForexManage.today.props.tmpl : Differenzen einzelner Dateien zw. Repository(kopie)
und eigener lokaler Arbeitsversion 14.)
svn
revert : Letzten Vorgang rückgängig machen 15.)
Sicherung
oder ‚taggen’ einer Version durch ‚kopieren’ zu einer anderen 16.)
|
||
http://mxcomsvn:666 -
http//:subversion.tigris.org |
svn
|
|
>add, >commit, >status, >diff
|
>svn |
19.12.2005 |
0.) Es soll mit ‚ausgechecktem’
Sourcecode gearbeitet werden (da beim auschecken eine eingefrorene svn-Kopie
erstellt wird, kann jede Änderung damit verglichen werden. 1.) |
||
http://mxcomsvn:666 -
http//:subversion.tigris.org |
svn
|
|
>dircmp, >compare, >directory, >rdiff
|
>dircmp |
19.09.2007 |
-l Ausgabe aller abweichenden Bytes (cmp -l) -d Vergleich mit diff anstelle von cmp -c Kontextvergleich mit diff anstelle von cmp -v Protokoll der durchgeführten Vergleiche dir1 1. Verzeichnis dir2 2. Verzeichnis |
||
|
diff
|
|
>>dealbus
>dbus,
>generalPublisher, >mxmlPress, >checkout, >co
|
>dealbus |
19.12.2005 |
0.) Es soll der ‘neue’ dealbus
ausgecheckt werden 1.)
svn checkout
http://mxcomsvn:666/svn/mxmlPress/trunk /home/f985757/dealbus 2.)
FFTUSD7730:/home/f985757/dealbus/mxmlPress$
ll 3.)
FFTUSD7730:/home/f985757/dealbus/mxmlPress/bin$ ls –lrt 4.)
FFTUSD7730:/home/f985757/dealbus/mxmlPress/etc$ ls –lrt 5.)
FFTUSD7730:/home/f985757/dealbus/mxmlPress/jbin$ ls –l 6.) Da die ‘mxcomdev.de.bnksdnerkb.com’
über ein samba share und dem Netzwerklaufwerk ‚f985757 on 'murdev.de.bnksdnerkb.com'
dem PC verfügbar ist, kann der ‚generische publisher’ namens ‚mxmlPress’ über
eclipse ‚New-> Java Project-> at external location-> samba
share-> dealbus-> mxmlPress’ geöffnet und bearbeitet werden (ausführen
geht nur direkt aus unix shell). |
||
ForexManage, ClearVision, GMI |
dealbus
|
|
>>Perl,
>>perl, >>pl
>scalar, >count
|
>split |
|
perl -n -e 'print
"\n",scalar(split("^B",$_));' trn_hdr.ODS_data Gibt die Anzahl
des Vorkommens des Trennungszeichens ^B pro Zeile an; kann man mit einem sort
–u ergänzt werden . . . |
||
Beispiel |
ShellScript |
|
>Array, >hash
|
>perl |
|
# Array aus Hash (%row ist als Hash definiert, @temp
als Array) my @temp = %$row; print STDOUT "Row of database is:@temp\n"; @$list = (sort keys %{$groupList{$group}}); while( my ($key, $index) = each(%field_map) ) { print
STDOUT "$$row{ $key }\n"; $$row{ $key
} =~ s/^\s+//; $$row{ $key
} =~ s/\s+$//; } |
||
Beispiel |
ShellScript |
|
>Unix
Befehl
|
>perl |
|
#
shell/unix-Befehle ausführen (Backquotes, system) print STDOUT
"AnzRec's: " . `cat $si_file_name | wc -l` . "\n"; system ("cat
$si_file_name"); # system zum
Ausführen des (shell)-sort Befehls einer Datei my @command = ("sort +5 -6 -t$delim -o
$filename.sort $filename.txt"); unless(! system(@command) ) { print "I
couldn't sort input file filename.txt"); die; } |
||
Beispiel |
ShellScript |
|
>Datanbankabfrage,
Datenbankdatensätze ausgeben
|
>perl |
|
my
$row; while
($row = $sth->fetchrow_hashref())
{ # get rid of white space in
database fields foreach
my $key (keys %$row)
{
$$row{ $key } =~ s/^\s+//;
$$row{ $key } =~ s/\s+$//;
print STDOUT "key:
'$key'\n";
print STDOUT "row:
'$$row{ $key }'\n";
} my
$bla = (keys %$row); print
STDOUT "bla: '$bla'\n"; my
@blo = (keys %$row); print
STDOUT "blo: '@blo'\n"; my
@ble = (values %$row); print
STDOUT "ble: '@ble'\n";
foreach my $index (values
%$row)
{
$$row{ $index } =~ s/^\s+//;
$$row{ $index } =~ s/\s+$//;
print
STDOUT "val: '$index'\n"; print STDOUT "row:
'$$row{ $index }'\n"; } |
||
Beispiel |
ShellScript |
|
>>java
>Umgebungsvariable, >environment
>variable, >JAVA_HOME
|
>PATH |
03.03.05 / 06.07.06
|
0.) Es soll die Umgebungsvariable 'PATH'
unter Windows gesetzt werden, damit z.B. 'eclipse' die jre (java runtime
environment) finden/ausführen kann - an sich wie unter Unix für einige
"Unix-nahe" Applikationen 1.) Start -> Settings(Einstellungen)
-> Control panel(Systemeinstellungen) -> System 2.) Advanced(Erweitert) -> Environment
variable(Umgebungsvariablen) 3.)
JAVA_HOME -> C:\Program
Files\JavaSoft\JRE\1.4.2_05\bin (PC spezifisch) 4.) PATH ->
C:\Sybase\ASEP;C:\Sybase\BIN;C:\Sybase\DLL;%JAVA_HOME% 5.) Prüfen -> Start -> Run ->
Cmd -> java -version -> durch PATH gesetzte Javaversion 6.) Umgebungsvariablen angucken: Start
-> Run -> ‚cmd’ set PATH (DOS-Fenster-Emulation) 7.) Anmerkung: Funktioniert
offensichtlich nur dann, wenn amn Admin-Rechte hat und dies für die
System-Variablen anlegen kann . . .(nur User-Varaiablen funktioniert nicht) |
||
www.eclipse.org‚
java.sun.com/reference/api/index.html |
java |
|
C:\Program Files\JavaSoft\JRE\1.5.0_07
C:\Sybase\ASEP;C:\Program Files\Sybase\Sybase
Central\win32;C:\Sybase\BIN;C:\Sybase\DLL
>ausführen, >run, >create
|
>Run |
21.12.2005
|
0.) Es soll ein (lauffähiges)
Java-Programm/Projekt angelegt werden (hier in eclipse) 1.) eclipse -> File -> New ->
Java Project -> Project name -> “Create project in workspace” 2.) Das Java Projekt kann noch nichts –
wird durch Klassen implementiert. Klassischerweise wird eine ‚main’-Klasse,
also: Das Java-Projekt markieren und neue Klasse anlegen mit File -> New
-> Class (Java Projekt = Source Folder) -> Name (der neuen Klasse)
-> Methoden -> public statis
void main 3.) Nun kann in der ‚main’- Methode der
Klasse die ersten Ausführungen angegeben werden, z.B 4.) Zum Ausführen des Java-Programms
entweder direkt im package explorer rechts auf das Java Project klicken –>
Run -> Java Application -> Run type -> Klasse auswählen, in der die
main Methode implementiert ist oder Menü -> Run -> Run.. -> Project
und Main class angeben -> Run 5.) In eclipse können aber auch über Help
-> Cheat sheets einfache Beispiel-Beschreibungen ausgeführt werden, um ein
kleines lauffähiges Java-Progamm zu erstellen |
||
|
Java |
|
>Zeitstempel,
>Dateiliste, >Liste, >Format, >DateFormat, >println
|
>Date, >File |
21.12.2005
|
0.)
Dateien in Liste sollen mit
Zeitstempel ausgeben werden |
||
|
Java
|
|
>Datum, >date, >toString,
>calendar, >Gregorian, >DATE, >MONTH
|
>Date, >File |
21.12.2005
|
0.)
Es soll das aktuelle Datum
ermittelt werden |
||
|
Java
|
|
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>>eclipse
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>Umgebungsvariable, >environment >variable,
>JAVA_HOME
+----------------------------------------------------------------------------------------------------
0.) Es soll die Umgebungsvariable 'PATH' unter Windows
gesetzt werden, damit z.B. 'eclipse' die jre (java runtime environment)
finden/ausführen kann - an sich wie unter Unix für einige "Unix-nahe"
Applikationen
1.) Start -> Settings(Einstellungen) -> Control
panel(Systemeinstellungen) -> System
2.) Advanced(Erweitert) -> Environment
variable(Umgebungsvariablen)
3.) JAVA_HOME -> C:\Program
Files\JavaSoft\JRE\1.4.2_05\bin (PC spezifisch)
4.) PATH ->
C:\Sybase\ASEP;C:\Sybase\BIN;C:\Sybase\DLL;%JAVA_HOME% (man hätte den Pfad auch
direkt hier hineinschreiben können; wird nur etwas unübersichtlich)
5.) Prüfen -> Start -> Run -> Cmd -> java
-version -> durch PATH gesetzte Javaversion
6.) Umgebungsvariablen angucken: Start -> Run -> ‚cmd’
set PATH (DOS-Fenster-Emulation) (hier sollte jetzt nicht JAVA_HOME sondern
dessen Inhalt aufgelöst erscheinen)
7.) Anmerkung: Funktioniert offensichtlich nur dann, wenn
amn Admin-Rechte hat und dies für die System-Variablen anlegen kann . . .(nur
User-Varaiablen funktioniert nicht) - 06.07.2006
+----------------------------------------------------------------------------------------------------
0.) Wenn aber das
Projekt bereits ein 'Ant'-build file enthält (ähnlich c-makefile), dann muss
der Pfad für das JDK (java davelopment kit) durch "JAVA_HOME" gesetzt
werden. Das JDK enthält dann sowohl das 'java.exe' als auch den Compilter
'javac.exe'
1.) Start
-> Settings(Einstellungen) -> Control panel(Systemeinstellungen) ->
System
2.) Advanced(Erweitert) -> Environment
Variables(Umgebungsvariablen) -> System variables (falls Rechte dazu)
3.) C:\Program Files\JavaSoft\JDK\jdk1.5.0_06\bin (PC
spezifisch) - 15.05.2007
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>Projekt,
>anlegen, >neu
+----------------------------------------------------------------------------------------------------
0.) Es soll ein
Programm - dass auch Java-Komponenten enthält - angeschaut, erweitert oder neu
angelegt werden
1.) Im Zweifelsfalle
erst einaml ein Java-Projekt anlegen
1.a.) Neu: File -> New -> Project -> Java
Project -> ‚Create new project in workspace’ oder
1.b.) Old: File -> New -> Project -> Java
Project -> ‚Create project from existing source’ -> Browse -> z.B.
openadaptor oder GF_IMPORT ... Wenn
die Sourcen auf Unix liegen, müssen diese zuvor als ‘share’ nach Windows
verbunden werden.
2.) Java Settings
2.a.) Source: Dann
wird die gesamte Dateistruktur als Projekt in 'eclipse' angelegt
2.b.) Projects:
Lassen sich auch noch ergänzen ?!
2.c.) Libraries:
Liste aller enthaltenen ‚jar’ files + die default ‘jar’s der run time
environment; Hier können weitere ‘jar’ ergänzt werden !!! Interessant, um für
das Projekt zur Verfügung stehende Funktionalität zu ergänzen – kommt z.B. für
den ‚openadaptor’ zum Tragen . . .
3.) Geht auch nachträglich:
RechteMausKlick -> Property -> Info | Builders | Build Path | . . .
+----------------------------------------------------------------------------------------------------
06.07.2006
+----------------------------------------------------------------------------------------------------
>build, >ant,
>compile
+----------------------------------------------------------------------------------------------------
0.) Es soll das
Projekt / der Sourcecode in Klassen bzw. Java Archivdateien
"übersetzt" werden (build)
1.) Dies wird
entweder über 'eclipse' selbst gesteuert oder aber über ein 'ant' build file
(ähnlich c makefile)
2.) Run -> External Tools -> External Tools
->
3.) Run ->
External Tools -> External Tools -> Main -> Targets -> eigenes
Projekt / Teil auswählen
oder
4.) Window ->
Show View -> Ant -> Dbnkelklick auf eigenes Projekt / oder auch alles
5.) Das erstellte
'jar' File kann per 'Properties' auf Aktualität geprüft werden (Zeitstempel)
+----------------------------------------------------------------------------------------------------
27.06.2007
+----------------------------------------------------------------------------------------------------
>checkout,
>svn
+----------------------------------------------------------------------------------------------------
0.) Es soll
bestehendes Projekt aus 'svn' (subversion) Versionierungsprogramm/Bestand
ausgecheckt werden
1.) Entweder über Eclipse: File -> New -> Other
-> SVN -> Projects from SVN
2.) URL:
http://mxcomsvn:666/svn/mxcomtools/
3.) User: 'f985757', passwd: 'F******#'
4.) dealbusFW -> trunk (Arbeitsversion)
oder
5.) Eclipse: Window -> Open Perspective -> Other
-> SVN Repository Exploring -> ... -> dealbusFW -> trunk
+----------------------------------------------------------------------------------------------------
09.05.2007
+----------------------------------------------------------------------------------------------------
>useful,
>nützlich, >Tipp und >Tricks, >Content Assist
+----------------------------------------------------------------------------------------------------
Ctrl Shift L ->
Key Assist mit Auswahl an nützlichen ‚Shortcuts’
+----------------------------------------------------------------------------------------------------
Ctrl 1 => um
Lösungsvorschlag für einen "rot unterkringelten Fehler" zu bekommen
+----------------------------------------------------------------------------------------------------
* Ctrl Space (Content
Assist) -> erscheint i.d.R. ein nützliches Kontextmenü mit Vorschlägen, z.B.
Klassen, Methoden, . . .
* F3 (Open Declaration)
* Alt Shift S = RechteMausTaset -> Source/Quelle
-> z.B. Generate Getter and Setters oder Generate Constructors . . .
Alt Shift S =
RechteMausTaset -> Source/Quelle -> z.B. Override/Implement Methods . . .
+----------------------------------------------------------------------------------------------------
06.07.2006
+----------------------------------------------------------------------------------------------------
>generic adaptor, >dealbusFW, >start,
>run, >process, >CAT, >KondorToMurexFXSpot, >eclipse
+----------------------------------------------------------------------------------------------------
0.) Es soll ein ausgechecktes
'dealbusFW' Projekt direkt aus 'eclipse'
heraus auf dem PC ausgeführt werden
1.) dealbusFW -> config -> dealbusFW.properties:
"dealbusFW.rootDir=."
(anstatt /opt/curplus/dealbusFW)
2.) dealbusFW -> config -> dealbusFW.properties:
" dealbusFW.verbose=true"
(damit man mehr sehen kann)
3.) dealbusFW -> repository ->
KondorToMurexFXSpot -> adaptor.properties: " dealbusFW.olkTransmitter=off"
4.) dealbusFW -> repository ->
KondorToMurexFXSpot -> openadaptor.props: ${AdaptorName}.SOURCE.ClassName =
com.drkw.dealbusFW.cookbook.MyLocalDealbusSource anstatt #${AdaptorName}.SOURCE.ClassName
= org.openadaptor.adaptor.jms.JMSSource (auskommentiert wenn man sich nicht mit
'dealbus' verbinden will)
+----------------------------------------------------------------------------------------------------
5.) Run -> Run -> Java Application -> New
-> Name: z.B. "StartCAT"
6.)
7.)
8.) Arguments ->
Program arguments: "KondorToMurexFXSpot" (der eigentliche Adapter;
java . . . ${ADAPTOR_NAME})
9.) Arguments ->
VM arguments: " -Dadaptor=KondorToMurexFXSpot
-Dproduction=false -Dlog4j.configDebug=false" (wichtig !!! hier wird
entschieden, ob Test oder Produktion: production=true/false)
10.) Run -> Run -> Start Application -> z.B. "StartCAT"
-> Run
11.) Im Fenster
"Console" können dann die Standardausgabe verfolgt werden . . .
+----------------------------------------------------------------------------------------------------
12.) Für 'debuggen'
gilt das Gleiche: Run -> Debug -> java Application -> z.B.
"StartCAT" -> Debug
+----------------------------------------------------------------------------------------------------
13.) Stbnken: Concole Fenster -> Menü ->
"rotes Quadrat" = Terminate
+----------------------------------------------------------------------------------------------------
16.05.2007
+----------------------------------------------------------------------------------------------------
>generic adaptor, >dealbusFW, >deploy,
>golive, >production, >CAT, >KondorToMurexFXSpot, >eclipse
+----------------------------------------------------------------------------------------------------
0.) Es soll ein
ausgechecktes 'dealbusFW' Projekt auf 'unix'
(Test/Produktion) implementiert werden
1.) Änderungen
prüfen mit: RechteMausKlick -> Team -> Synchronize with Repository ->
Incoming mode (Menü: bl Pfeil links)
2.) Dateien, die
sich gezwungenermassen in lokaler Kopie ändern (transfers, logs, classes, . .
.) können von der Prüfung ausgeschlossen werden, mit: RechteMausKlick -> Add
to svn:ignore
3.) Mit DbnkelKlick
auf betreffende Datei können die Unterschiede angezeigt werden
4.) Will man die
Änderungen des Repository auf die lokale/ausgechekte Version übertragen ->
Update
+----------------------------------------------------------------------------------------------------
5.) Änderungen
prüfen mit: RechteMausKlick -> Team -> Synchronize with Repository ->
Outcoming mode (Menü: gr Pfeil rechts)
6.) Will man die
Änderungen des Repository auf die lokale/ausgechekte Version
"überbügeln" -> Override & Update
7.) Will man
hingegen doe lokalen Änderungen dann tatsächlich "einchecken" ->
Commit (sollte man sich aber sicher sein)
+----------------------------------------------------------------------------------------------------
8.) Historie ansehen
-> Java Perspective -> Package Explorer -> Datei auswählen ->
RechteMausKlick
9.) Team -> Show Resource History -> SVN History
-> Revision -> Dbnkelklick (oder RMK -> Compare Current with xxxx)
+----------------------------------------------------------------------------------------------------
2.) dealbusFW -> config -> dealbusFW.properties:
"dealbusFW.rootDir=/opt/curplus/dealbusFW" (prüfen)
3.) dealbusFW -> config -> dealbusFW.properties:
" dealbusFW.verbose=false"
(optional für Produktion)
4.) nur Test: dealbusFW -> repository ->
KondorToMurexFXSpot -> openadaptor.props:
${AdaptorName}.SOURCE.ClassName =
com.drkw.dealbusFW.cookbook.MyLocalDealbusSource anstatt (ohne 'dealbus' Verbindung)
+----------------------------------------------------------------------------------------------------
11.06.2007
+----------------------------------------------------------------------------------------------------
5.) Run -> External Tools -> External Tools
-> Ant Build -> "build dealbusFW" -> Run
5.a.) buildfile: ${workspace_loc:/dealbusFW/build/build.xml},
5.b.) basedir: ${workspace_loc:/dealbusFW}) . . .
führt quasi das 'build.xml'
5.c.) Nachsehen neu
erstelltes Verzeichnis Package Explorerer -> deploy -> "dealbusFW_*_dist.jar" files
6.) Copy "dealbusFW_KondorToMurexFXSpot_dist.jar"
to a share, z.B. "f985757@fftusp7712:/home/f985757/TRANS"
7.) scp f985757@fftusp7712:/home/f985757/TRANS/dealbusFW_KondorToMurexFXSpot_dist.jar
/home/f985757
8.) chmod 755 dealbusFW_KondorToMurexFXSpot_dist.jar
9.) sudo -u curplus cp -p
dealbusFW_KondorToMurexFXSpot_dist.jar /opt/curplus/dealbusFW
10.) check if interface is still running: /usr/ucb/ps
-auxwww | grep dealbusFW (stop in case)
11.) cd
/opt/curplus/dealbusFW/cmd; ./stopAdaptorProd.sh KondorToMurexFXSpot (or submit
maetro job)
12.) /opt/curplus/dealbusFW$
sudo -u curplus rm -r /opt/curplus/dealbusFW/repository/KondorToMurexFXSpot/*
13.) /opt/curplus/dealbusFW$
sudo -u curplus jar -xf dealbusFW_KondorToMurexFXSpot_dist.jar
14.) ./prepare.sh (zuerst im prepare.sh
selbst die ^M rausnehmen und dann ausführen -> führt dos2unix aus)
+----------------------------------------------------------------------------------------------------
24.05.07
+----------------------------------------------------------------------------------------------------
>test, >feeder, >dealbusFW, >Click&Trade,
>CAT, >KondorToMurexFXSpots, >Pass to OLK, >Olk_I_SP*data
+----------------------------------------------------------------------------------------------------
0.) Es soll ein
Adapter, z.B. der 'click & trade' Adapter "KondorToMurexFXSpots" getestet
werden
1.) Wenn er läuft
(egal ob mit 'dealbus' verbunden oder nicht) können die Input Dateien aus Prod
(FFTUSP7730:/opt/curplus/dealbusFW/repository/KondorToMurexFXSpot/audit) in das
Feeder-Verzeichnis des Projekts (C:\workspace\dealbusFW\repository\KondorToMurexFXSpot\feeder)
kopiert werden - diese werden dann verarbeitet (so als ob vom 'dealbus'
subscribed)
2.)
+----------------------------------------------------------------------------------------------------
16.05.2007
+----------------------------------------------------------------------------------------------------
>click &
trade, >Struktur, >Reihenfolge, >worflow, >OLKConverter.java
+----------------------------------------------------------------------------------------------------
RunDealbusAdaptor.java: main(String[])
with Threads:
[main]
[DealbusAdaptorRunner-KondorToMurexFXSpot]
[KondorToMurexFXSpot.Controller]
[SOURCE],[HOSPITAL_SOURCE],[DIRECTORY_SOURCE],[SOURCE-listen],[OLKTransmitter-1],[MailTransmitter],[CleanUpRunner]
ValidatioPipeFXSpot.java: public boolean isValid(DataObject
dob)
OLKSink.java: protected void handleSingleTrade(DataObject dob)
OLKConverter.java: public static List<String> transformOLK(DataObject
dob, Map<Str,Str> dobMap, IOLKTransform transformer)
transformer.beforeMapping(dob, dobMap);
OLKSinkFXSpot.java: public void beforeMapping(DataObjects dob,
Map<String, String> attributes)
OLKSinkFXSpot.java: protected boolean isPrecMetals(DataObject dob)
transformer.afterMapping(dob, dobMap,
oldMap);
OLKSinkFXSpot.java: public void afterMapping(DataObjects dob,
Map<Str,Str> mappedAttr, Map<Str,Str> unmappedAttr)
OLKSinkFXSpot.java: protected void adjustBuySellAttributes(DataObjects
dob, Map<Str,Str> mappedAttr)
OLKSinkFXSpot.java: protected boolean isPrecMetals(DataObject dob)
DealbusConverter.resolveMacros(dobMap);
DealbusConverter.resolveDefaults(dobMap);
DealbusConverter.resolveForecedValues(dobMap);
if (DealbusConverter.isSelected("approve",
dobMap) && transformer.transferApproved(dobMap))
. . .
OLKSinkFXSpot.java: public boolean transferApproved(Map<String, String> mappedAttr)
return resolveTemplateOLK(dobMap, template,
false, templatePath);
. . .
+----------------------------------------------------------------------------------------------------
25.06.2007
+----------------------------------------------------------------------------------------------------
>workspace
wechseln / duplizieren
+----------------------------------------------------------------------------------------------------
0.) Es soll ein
bestehender 'workspace' dupliziert werden, z.B. um anderen Pfad / Laufwerk zu
nutzen
1.) Default liegt
unter Windows-spez. Benutzerdaten: "C:\Documents and
Settings\wagenee\workspace"
2.) Ab und Inklusive
'workspace' an neuen Ort kopieren, z.B: "C:\workspace"
3.a.) 'eclipse'
öffnen und entweder beim Start bereits den neuen 'workspace' auswählen oder
3.b.) File -> Switch Workspace -> Browse -> "C:\workspace"
-> auswählen
+----------------------------------------------------------------------------------------------------
16.05.2007
+----------------------------------------------------------------------------------------------------
>jad, >decompiler, > http://www.kpdus.com/jad.html#download
+----------------------------------------------------------------------------------------------------
1.) copy 'jad.exe' to e.g. "C:\eclipse\jad.exe"
2.) copy eclipse plugin 'jar' into eclipse plugin dir,
e.g. "C:\eclipse\plugins\jadclipse_3.1.0.jar"
3.) start eclipse one more time
4.) go to eclipse: Windows -> Preferences -> Java
-> JadClipse (only appears when plugin is copied)
5.) set "Path to decompiler", e.g. "C:\eclipse\jad.exe"
(war zumindest am 08.02.2007 so bei Dr)
6.) then a new project has to opended including the
library / jar file / call files
7.) if everything is correct the opened 'class' files
will be decompiled automatically
+----------------------------------------------------------------------------------------------------
8.) If it doesn't work, run 'jad.exe: directly on
windows
9.) jad.exe <source code input file>.class
10.) Will create / decompile a <source code input
file>.jad file
+----------------------------------------------------------------------------------------------------
08.01.2007
+----------------------------------------------------------------------------------------------------
>plugin,
>feature, >software >update
+----------------------------------------------------------------------------------------------------
0.) Es soll ein
(weiteres) plugin in eclipse installiert werden
1.) Grundsätzlich
gibt es zwei Möglichkeiten: Manuell oder automatisch
2.) Manuell: jar im
Internet finden (z.B. unter "http://www.eclipse-plugins.info/eclipse/plugins.jsp"),
runterladen und im eclipse Verzeichnis auspacken (eclipse/plugin &
eclipse/feature), eclipse neu starten -> sollte unter Windows ->
preferences aufgelistet sein (insofern es in einem eigenem fenster erscheint)
3.) Wichtig: Zuerst
proxy setzen: Windows -> Preferences -> Install/Update -> incache.gb.drkw.net, 8080 (first line in http://pac-file.de.bnksdnerkb.com/pac/pacserver.pl)
4.) Automatisch:
Help -> Software Update -> Find and install -> Search for new
features (oder auch nur updates)
5.) New Remote Site
-> Name (beliebig) -> URL muss vorher bekannt sein, d.h. googlen . . .
6.) Wenn schon
angelegt, dann halr anklicken -> Finish -> Mirror (oder Default) ->
weitere Unterkategorien anklicken
7.) Wenn dann
festgestellt wird, dass ein notwendiges plugin fehlt, muss dies vorher
installiert werden, d.h. go back to 3.)
8.) Vorsicht: Wenn
man vorher schon manuell versucht hat, das plugin zu installieren, kann es zu
Komplikationen kommen. In diesen Fall dann in die Verzeichjnise 'plugin' und
'feautures', um die entsprechenden jar Dateine zu löschen
9.)
+----------------------------------------------------------------------------------------------------
Web Tools Platform(WTP/WST): http://download.eclipse.org/webtools/updates
Graphical Editor Framework(GEF): http://www.eclipse.org/gef
Eclipse Modeling Framework(EMF): http://download.eclipse.org/tools/emf/updates
Orangevolt XSLT Plugin for Eclipse: http://eclipsexslt.sourceforge.net/update-site
Test and performance tools platform(TPTP): http://eclipse.org/tptp/updates
http://download.eclipse.org/modeling/emf/updates/site.xml
+----------------------------------------------------------------------------------------------------
27.09.2007
Um einen Zeilenumbruch in eine Bashvariable zu bekommen, muss
man bisschen tricksen:
#> var=`echo -e "a\nb"`
#> var=${var:1:1}
#> echo "$var"
#>
Wie man sieht, gibt echo "$var" zwei Zeilenumbrüche aus, der erste steht in der
Variablen, der zweite kommt von echo
selbst.
Steht ${var:1:1} zum Herausschneiden des
Substring nicht zur Verfügung (etwa in einer alten Korn-Shell), kann man diesen
Code verwenden:
#> var=${var#a}
#> var=${var%b}
Teilweise gibt es auch den Switch -e bei echo nicht, dann gibt echo "a\nb" bereits a und b
in separaten Zeilen aus.
+----------------------------------------------------------------------------------------------------
>Vorgehensweise,
>Erweiterung, >Funktionen
+----------------------------------------------------------------------------------------------------
0.) Es soll bestehende
Funktionalität erweitert werden, z.B. dealbus publisher/subscriber ‚props’
Einträge
1.) Im ‚prop’ file
nachsehen -> Project ‚GFSub01’ -> etc -> „DevReceiver.Murex.Fx.Options.props“
-> A.C2.ClassName=org.openadaptor.adaptor.standard.FileSink (dies ist die
übergeordnete Klasse, deren Methoden/Funktionen genutzt werden sollen)
2.) Projekt
‚openadaptor’ -> src -> org.openadaptor.adaptor.standard ->
FileSink.java -> z.B. init() oder moveOutputFile()
oder
3.) Javadocs ->
index.html -> org.openadaptor.adaptor.standard -> FileSink (besser; mehr
Beschreibung)
4.)
+----------------------------------------------------------------------------------------------------
06.07.2006
+----------------------------------------------------------------------------------------------------
>views, >outline, >usefule views, >windows,
>classes, >Klassen, >Definitionen
+----------------------------------------------------------------------------------------------------
0.) Dbnkelklick auf
ein Fenster bewirkt, dass es den gesamten Bildschirm ausfüllt
1.) Window -> Show views -> Outline
(Klassen-Definitionen: grün: public, gelb: protected, rot: private)
2.)
+----------------------------------------------------------------------------------------------------
25.06.2007
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>>bash
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>PS1, >prompt, >cursor
+----------------------------------------------------------------------------------------------------
# ksh
PS1='${LOGNAME}@${HOST}:${PWD}$ '
#bash
Primäres Prompt setzen: PS1="\u@\h:\w$ "
(\u...User, \h...Host, \w...Working Directory)
Einstellungen
ansehen: set –o, setzen: set -o
<Option>, löschen: set +o <Option>
PS1="\u@\h:\w$ "
alias "ll=ls –lrt"
set –o vi
#summit Umfeld
PS1='$USER@$HOSTNAME:$PWD$ '
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>touch, Datei Zeitstempel auktualisieren / umsetzen
+----------------------------------------------------------------------------------------------------
touch -m 09081200 LME_RATES_20060908.csv
| |
Zeit Datei
| Tag
Monat
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
>uplmu.ksh, >
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
31.12.2007
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------
+----------------------------------------------------------------------------------------------------